HOWTO: Printing Tips for the Command Line

Forum rules
Share your brain ;)
User avatar
Launfal
Dirty Laundry
Posts: 141
Joined: Tue Mar 04, 2014 12:50 am
Location: Ohio, USA

HOWTO: Printing Tips for the Command Line

Unread post by Launfal » Tue May 27, 2014 3:46 am

OK, so I was playing around with printing from the command line, since I was using Wordgrinder, which doesn't print. I eventually ditched it because I couldn't get used to the screen display, but I did learn how to print some pretty nice looking documents with some command-line tools. I'm back to Vim, and :ha, but if your favorite editor doesn't print (or you're stuck with one that doesn't print) here's what you can do to get by.

1. Edit your document, then save it. Then save it again. Make a backup, then another.
2. See above.
3. fold --spaces [your_doc] > [print.fold] - this gives you a hard-wrapped document with no broken words.
4. pr --form-feed --length=85 [print.fold] > [print_your_doc] - the reason for that long page-length will be obvious in a second. At this stage, if you want a custom header, you'd add it with the --header=[header] option. For double-spaced documents, you'd add a --double-space option.
5. lp -o cpi=12 -o lpi=8 -o page-left=72 [print_your_doc] - This gives you a nice, readable output with enough margins all around to look pretty decent.

If you want double-spaced docs, or anything other than a quick and dirty, rough-draft quality document, you'd have to explore the different options in pr, but the above steps will get you where you're going without having to screw around with word processors or learning some Latex voodoo-ery. My first few drafts are always plain text, so I'm not even thinking markup or formatting until almost the end of the road.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Printing Tips for the Command Line

Unread post by machinebacon » Tue May 27, 2014 7:17 am

excellent tips here, thanks so much!
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: HOWTO: Printing Tips for the Command Line

Unread post by wuxmedia » Tue May 27, 2014 7:34 am

That's great Lawnfull, Nice guide.
I heard that lp(r) was supposed to be able to print PDF's from the commandline too, I didn't have much luck though 8)
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Printing Tips for the Command Line

Unread post by machinebacon » Tue May 27, 2014 8:47 am

wux, does xpdf do it? If no, we should investigate (because both use lpr)

xpdf -cmd some_small.pdf

click the printer icon, choose the printer and OK. Minimize xpdf, and switch to the terminal. In the xpdf output find "lp" and see what command it uses there to print.
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: HOWTO: Printing Tips for the Command Line

Unread post by GekkoP » Tue May 27, 2014 10:13 am

I still use this script. :)

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: HOWTO: Printing Tips for the Command Line

Unread post by wuxmedia » Tue May 27, 2014 12:13 pm

^ will try both, I ended up install some huge gnomish pdf reader because it had the 'standard' printer dialog popup box.
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Printing Tips for the Command Line

Unread post by machinebacon » Tue May 27, 2014 12:18 pm

^ ...which is probably coming from system-config-printer or so. For kicks, try apvlv, atril, mupdf, pdfviewer or the good-old epdfview (not in the repos anymore, but binaries are available)
..gnutella..

Post Reply