Command-Line Printing Options
Setting the Default Printer
If you normally use a particular printer, you can tell CUPS to use it by default using the lpoptions(1) command:
lpoptions -d printer
Creating Saved Options
Saved options are supported in CUPS through printer instances. Printer instances are, as their name implies, copies of a printer that have certain options associated with them. Use the lpoptions command to create a printer instance:
lpoptions -p printer/instance -o name=value ...
The -p printer/instance option provides the name of the instance, which is always the printer name, a slash, and the instance name which can contain any printable characters except space and slash. The remaining options are then associated with the instance instead of the main queue. For example, the following command creates a duplex instance of the LaserJet queue:
lpoptions -p LaserJet/duplex -o sides=two-sided-long-edge
Instances do not inherit lpoptions from the main queue.
Setting the Orientation
The -o landscape option will rotate the page 90 degrees to print in landscape orientation:
lpr -o landscape filename
The -o orientation-requested=N option rotates the page depending on the value of N:
- -o orientation-requested=3 - portrait orientation (no rotation)
- -o orientation-requested=4 - landscape orientation (90 degrees)
- -o orientation-requested=5 - reverse landscape or seascape orientation (270 degrees)
- -o orientation-requested=6 - reverse portrait or upside-down orientation (180 degrees)
lpr -o sides=one-sided filename
Selecting a Range of Pages
The -o page-ranges=pages option selects a range of pages for printing:
lpr -o page-ranges=1 filename
lpr -o page-ranges=1-4 filename
lpr -o page-ranges=1-4,7,9-12 filename
As shown above, the pages value can be a single page, a range of pages, or a collection of page numbers and ranges separated by commas. The pages will always be printed in ascending order, regardless of the order of the pages in the page-ranges option.
The default is to print all pages.
The page numbers used by page-ranges refer to the output pages and not the document's page numbers. Options like number-up can make the output page numbering not match the document page numbers.
Selecting Even or Odd Pages
Use the -o page-set=set option to select the even or odd pages:
lpr -o page-set=odd filename
lpr -o page-set=even filename
The default is to print all pages.
The -o number-up=value option selects N-Up printing. N-Up printing places multiple document pages on a single printed page. CUPS supports 1, 2, 4, 6, 9, and 16-Up formats; the default format is 1-Up:
lpr -o number-up=1 filename
lpr -o number-up=2 filename
lpr -o number-up=4 filename
lpr -o number-up=16 filename
The -o page-border=value option chooses the border to draw around each page:
- -o page-border=double; draw two hairline borders around each page
- -o page-border=double-thick; draw two 1pt borders around each page
- -o page-border=none; do not draw a border (default)
- -o page-border=single; draw one hairline border around each page
- -o page-border=single-thick; draw one 1pt border around each page
The -o number-up-layout=value option chooses the layout of the pages on each output page:
- -o number-up-layout=btlr; Bottom to top, left to right
- -o number-up-layout=btrl; Bottom to top, right to left
- -o number-up-layout=lrbt; Left to right, bottom to top
- -o number-up-layout=lrtb; Left to right, top to bottom (default)
- -o number-up-layout=rlbt; Right to left, bottom to top
- -o number-up-layout=rltb; Right to left, top to bottom
- -o number-up-layout=tblr; Top to bottom, left to right
- -o number-up-layout=tbrl; Top to bottom, right to left
Scaling to Fit
The -o fit-to-page option specifies that the document should be scaled to fit on the page:
lpr -o fit-to-page filename
The default is to use the size specified in the file.
This feature depends upon an accurate size in the print file. If no size is given in the file, the page may be scaled incorrectly!
CUPS supports several options that are only used when printing plain text files. These options have absolutely no effect on PostScript, PDF, HP-GL/2, or image files. Setting the Number of Characters Per Inch
The -o cpi=value option sets the number of characters per inch:
lpr -o cpi=10 filename
lpr -o cpi=12 filename
lpr -o cpi=17 filename
The default characters per inch is 10.
Setting the Number of Lines Per Inch
The -o lpi=value option sets the number of lines per inch:
lpr -o lpi=6 filename
lpr -o lpi=8 filename
The default lines per inch is 6.
Setting the Number of Columns
The -o columns=value option sets the number of text columns:
lpr -o columns=2 filename
lpr -o columns=3 filename
The default number of columns is 1.
Setting the Page Margins
Normally the page margins are set to the hard limits of the printer. Use the -o page-left=value, -o page-right=value, -o page-top=value, and -o page-bottom=value options to adjust the page margins:
lpr -o page-left=value filename
lpr -o page-right=value filename
lpr -o page-top=value filename
lpr -o page-bottom=value filename
lpr -o page-left=value -o page-right=value -o page-top=value -o page-bottom=value filename
The value argument is the margin in points; each point is 1/72 inch or 0.35mm.
The -o prettyprint option puts a header at the top of each page with the page number, job title (usually the filename), and the date. Also, C and C++ keywords are highlighted, and comment lines are italicized:
lpr -o prettyprint filename
Turning Off Text Wrapping
The -o nowrap option disables wrapping of long lines:
lpr -o nowrap filename
CUPS supports several options that are only used when printing image files. These options have absolutely no effect on PostScript, PDF, HP-GL/2, or text files.
The -o position=name option specifies the position of the image on the page:
- center - Center the image on the page (default)
- top - Print the image centered at the top of the page
- left - Print the image centered on the left of page
- right - Print the image centered on the right of the page
- top-left - Print the image at the top left corner of the page
- top-right - Print the image at the top right corner of the page
- bottom - Print the image centered at the bottom of the page
- bottom-left - Print the image at the bottom left corner of the page
- bottom-right - Print the image at the bottom right corner of the page
The -o scaling=percent, -o ppi=value, and -o natural-scaling=percent options change the size of a printed image:
lpr -o natural-scaling=percent filename
The scaling=percent value is a number from 1 to 800 specifying the size in relation to the page (not the image.) A scaling of 100 percent will fill the page as completely as the image aspect ratio allows. A scaling of 200 percent will print on up to 4 pages.
The ppi=value value is a number from 1 to 1200 specifying the resolution of the image in pixels per inch. An image that is 3000x2400 pixels will print 10x8 inches at 300 pixels per inch, for example. If the specified resolution makes the image larger than the page, multiple pages will be printed to satisfy the request.
The natural-scaling=percent value is a number from 1 to 800 specifying the size in relation to the natural image size. A scaling of 100 percent will print the image at its natural size, while a scaling of 50 percent will print the image at half its natural size. If the specified scaling makes the image larger than the page, multiple pages will be printed to satisfy the request.
- Awards & Honors
- About Us
- Student Engagement and Support
- Masters Program
- Ph.D. Program
- Financial Information
- Prospective Students
- Incoming Students
- Current Students
- Curricular Practical Training
- Grad Student Talks
- UTCS Direct
- Audio & Visual
- Change SMTP/Outgoing Mail Password
- Cluster Node Status
- Grad Office Assignments
- Laptop Encryption
- List of Public UNIX Hosts
- Meeting Rooms
- Public Labs
- Shop Req (Hardware Issues/Requests)
- Software Downloads
- Software Request Form
- System & Facilities Blog
- Tech Staff Updates Blog
- UTCS IT Policies