3

Printing a text file with lpr produces output with a large Monaco font and very thin margins. Is there a way to change the font and the margins when you use lpr on OS X?

5

lp allows you to specify margins and text size. According to the man lp:

-o cpi=N
     Sets the number of characters per inch to use when printing a text file. The default is 10.

-o lpi=N
     Sets the number of lines per inch to use when printing a text file. The default is 6.

-o page-bottom=N

-o page-left=N

-o page-right=N

-o page-top=N
     Sets the page margins when printing text files. The values are in points - there are 72 points to the inch.

EXAMPLES

Print a double-sided legal document to a printer called "foo":
    lp -d foo -o media=legal -o sides=two-sided-long-edge filename

Print an image across 4 pages:
    lp -d bar -o scaling=200 filename

Print a text file with 12 characters per inch, 8 lines per inch, and a 1 inch left margin:
    lp -d bar -o cpi=12 -o lpi=8 -o page-left=72 filename
4

I defined a command mylpr (in ~/bin) as follows:

#!/bin/bash
ENSCRIPT="--no-header --margins=36:36:36:36 --font=Courier11 --word-wrap --media=Letter"
export ENSCRIPT
/usr/bin/enscript -p - $1 | /usr/bin/lpr

then I also added lines

(require 'lpr)
(setq my-print-command "~/bin/mylpr")
(setq lpr-command my-print-command)

to my ~/.emacs and ~/.xemacs/custom.el files. This took care of all my instances of printing in 12-pt Monaco without margins.

2
  • oops... I hope what I posted above is clear enough... I can't edit or comment, so I thank any other user who will do it. Notice that there should be a ";", or a new line, after "export ENSCRIPT". – user119153 Feb 19 '12 at 20:04
  • Fixed up for you :) – Simon Sheehan Feb 19 '12 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.