Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Print in landscape mode from the command line UNIX
Just a quick one today - for anyone frustrated by the lack of a landscape option in lpr for printing from the command line, take heart! Just use enscript -r. enscript has all kinds of fun options to play with - everything from printing in duplex to changing fonts, printing in columns, and rotating pages. Lots of opportunities for scripting -- please post any good ones you've got! Here's an alias to get you started:
  alias lprint 'enscript -h -r -E -DDuplex:true -fCourier7 -Ppsk7'
Explanations: -h no header page, -r landscape, -E pretty-print (syntax-based font changing -- very slick when used on code, although I occasionally get a parsing error), -f smaller font, -P set the printer.

Enjoy!
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,843 views]  

Print in landscape mode from the command line | 7 comments | Create New Account
Click here to return to the 'Print in landscape mode from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Print in landscape mode from the command line
Authored by: kirkmc on May 22, '03 11:01:55AM

The problem is not lp, the problem is the lp man page.

From the CUPS help:

Setting the Orientation

The -o landscape option will rotate the page 90 degrees to print in landscape orientation:

lp -o landscape filename
lpr -o landscape filename




[ Reply to This | # ]
Print in landscape mode from the command line
Authored by: eredhuin on May 22, '03 11:10:11PM

FYI - as I just discovered

http://localhost:631

has all you want to know about CUPS



[ Reply to This | # ]
Print in landscape mode from the command line
Authored by: kirkmc on May 22, '03 11:42:22AM

... and enscript looks like it only works with PostScript printers...

Kirk



[ Reply to This | # ]
Print in landscape mode from the command line
Authored by: Han Solo on May 22, '03 09:04:10PM
Yes, but with one other tool, you could create a PDF file from the command line (including in landscape mode if desired) and then print that to any printer.

First, use -pfilename instead of -Pprintername. This will write the output to a PostScript file.

Next, use ps2pdf to convert your newly created filename.ps to filename.pdf. ps2pdf is available from numerous places, including as part of a GhostScript install (or via Fink).

Finally, use regular old lpr to print the PDF file you created in the second step.

[ Reply to This | # ]

Print in landscape mode from the command line
Authored by: RalfM on May 22, '03 10:53:14PM
enscript -DDuplex:true -ptestfile.ps testfile ; ps2pdf testfile.ps testfile.pdf ; lpr testfile.pdf

vs

lp -o landscape testfile

?

Hmmm... what to choose?

I agree with an earlier post. Read the cups manpage.

[ Reply to This | # ]

Print in landscape mode from the command line
Authored by: eredhuin on May 22, '03 11:02:12PM

I fiddled briefly and came up with the one-liner

enscript -h -r -G -E -2 --color -i 2 -fCourier7 -o - fwdtest.cpp | ps2pdf - | lpr

Then I create a script in ~/bin/lprint.sh

#!/bin/sh
for k in $* ; do
enscript -h -r -G -E -2 --color -i 2 -fCourier7 -o - $k | \
ps2pdf -|lpr
done

and made it executable

chmod +x ~/bin/lprint.sh



[ Reply to This | # ]
Print in landscape mode from the command line
Authored by: tcurtin on May 23, '03 08:47:02AM

Aha - thanks for pointing out the -o option! (Untrustworthy man pages - that's rather evil...) That's good for printing normally, but enscript has quite a few other options that make it worthwhile (two sided printing, printing in columns, page labeling, pretty-printing, etc).

Now maybe a hint on how to alter man pages...

;)



[ Reply to This | # ]