FSUMATH

Printer Command-line Options


LPR Command-line Options

Printer Selection

To send a job to a printer other than your default, use the "-P" flag followed by the name of the printer, as in:

   lpr -Pmch406 filename.pdf

This will print the file filename.pdf to the printer mch406.

For information about permanently changing your default printer or using another printer from within applications, see the following link:

How to change your printer


Duplex Printing

To duplex print to lw using the command line, use the "-o" flag with the "sides" option as follows:

   lpr -Plw -o sides=two-sided-long-edge myfile.ps
   lpr -Plw -o sides=two-sided-short-edge myfile.ps

The first line above would print the file myfile.ps double-sided with the binding on the long edge of the paper. This is the most commonly used method and corresponds to pages formatted in portrait mode.

The second line above would print the file myfile.ps double-sided with the binding on the short edge of the paper. This corresponds to pages formatted in landscape mode.

The -Plw is not necessary if lw is your default printer.

For information about duplex printing from within applications, see the following link:

How to duplex print to grad lab printer LW


Page Selection

The way to print specific pages using lpr is to use the "-o" flag with the "page-ranges" option. You can use a dash to specify a range or give a list of pages separated by commas or even mix them both, as in:

1-5 would select pages 1 through 5
1-2,5,10-12 would select pages 1 & 2, page 5, and pages 10 through 12

The entire command would look like the following examples:


   lpr -o page-ranges=1-5 filename.pdf

would print pages 1-5 of the file filename.pdf to your default printer.


   lpr -o page-ranges=1-4,9 myfile.pdf

would print pages 1-4 and page 9 of the file myfile.pdf to your default printer.


Multiple Pages per Sheet (N-Up options)

You can print multiple document pages per sheet of paper using "-o" flags with the following options:

number-up Number of pages per printed page; 1, 2, 4, 6, 9, and 16 are supported.
number-up-layout String representing how the pages will be arranged on the sheet
btlr Bottom to top, left to right
btrl Bottom to top, right to left
lrbt Left to right, bottom to top
lrtb Left to right, top to bottom (default)
rlbt Right to left, bottom to top
rltb Right to left, top to bottom
tblr Top to bottom, left to right
tbrl Top to bottom, right to left

Examples:

To print a standard portrait-formatted document 4 pages per sheet, use

   lpr -o number-up=4 document.pdf

In this case, the default layout of lrtb is used, so the pages are printed left to right, top to bottom as in:

1 2
3 4


To print a standard landscape-formatted document 4 pages per sheet, use

   lpr -o number-up=4 -o number-up-layout=btlr document.pdf

In this case, the layout of btlr is given, so the pages are printed bottom to top, left to right as in:

2 4
1 3

so that when the page is rotated into landscape, it appears as:

   1       2   
   3       4   


Combining Options

Any number of options can be combined, but remember that each one needs a separate "-o" flag in front of it.


Note that when combining the Page Selection option with the N-Up option, page numbers given via "page-ranges" will correspond to the numbers of the printed sheet, not the page numbers of the original document. For example:

If document.pdf is a 12 page portrait-formatted pdf file, then the following command

   lpr -o number-up=4 -o page-ranges=2 document.pdf

will print sheet two of the N-Up format, which will correspond to pages 5-8 of the original document.


The following is an example of combining all of the options presented on this page. Assume that document.pdf is a 25 page portrait-formatted pdf file. The following command

   lpr -Plw -o sides=two-sided-long-edge -o number-up=6 -o page-ranges=2-3 document.pdf

will duplex print sheets 2 and 3 of the N-Up format, which will correspond to pages 7-18 of the original document, so that sheet 1 (pages 7-12) is on the front side of the printed page and sheet 2 (pages 13-18) is on the back side of the printed page.

Note that the -Plw is explicitly given as a reminder that, for now, duplex printing only works to printer lw. It is not necessary if lw is set as your default printer.