4

Shell Trick #1: Show me the PDF

view full story
linux-howto

http://forums.fedoraforum.org – Show me the PDF I've been using Linux for many years now, and have come up with some cool TRICKS that some of you may find useful. I hope you enjoy them as much as I do. I'll be posting them at random on this site, as time permits. :) Trick #1: Show me the PDF Have you ever been logged onto a System, trying to read a MAN PAGE or another TEXT document and said, that would be nice if I could just have it pop up as PDF? If so, try this: Requirements: a) Enscript installed on Linux Server b) PuTTY Terminal Emulator for Windows c) PDFCreator (from SourcForge) installed on Windows Workstation, with Auto-Save Option enabled and the Open in Default PDF Viewer option enabled. You must also set PDFCreator as the default printer to send output to in PuTTY. Copy and Paste the following code into a BASH script on your linux server called "pdfit" Code: #!/bin/bash # script: pdfit # Capture stream and convert to Postscript cat $@ | enscript -p stream.$$.ps # Open/Close VT Compatible Transparent/Passthrough Print Channel, and Send File printf "\033[5i" cat stream.$$.ps printf "\033[4i" # Clean-up workfile rm -f stream.$$.ps # Exit Clean exit 0 *** Copy/Put pdfit script into executable path, and give execute permissions. Eg. mv pdfit /usr/local/bin or /usr/bin and chmod +x pdfit Sample Usages: pdfit <filename> cat <filename> | pdfit man <command> | pdfit *** I recommend the use of FOXIT PDF READER, much, much faster than Adobe. If you are PDF'ing a very large file, this may take some time. More so if the stream is being passed via from an External Source (NOT ON YOU LAN). But it's still very fast, in my opinion *** You imagination is your limitation. I have a custom print script written specifically for PCL and TEXT based print streams for PDF Generation in this fashion. I've also added additional functionality such as usage of Overlays/Watermarks, Format Manipulation using GREP/SED/AWK based on Job Type, etc... A lot of which is specific to the software my company runs, as we are still utilizing a character based software. It's actually quite neat. About 1000 lines of BASH code :cool: (HowTos)