2 <!-- SECTION: Getting Started -->
4 <TITLE>Command-Line Printing and Options
</TITLE>
5 <LINK REL=
"STYLESHEET" TYPE=
"text/css" HREF=
"../cups-printable.css">
9 <H1 CLASS=
"title">Command-Line Printing and Options
</H1>
11 <P>CUPS provides both the System V (
<A
12 HREF=
"man-lp.html">lp(
1)
</A>) and Berkeley (
<A
13 HREF=
"man-lpr.html">lpr(
1)
</A>) printing commands for printing
14 files. In addition, it supported a large number of standard and
15 printer-specific options that allow you to control how and where
16 files are printed.
</P>
19 <H2 CLASS=
"title"><A NAME=
"BASICS">Printing Files
</A></H2>
21 <P>CUPS understands many different types of files directly,
22 including text, PostScript, PDF, and image files. This allows you
23 to print from inside your applications or at the command-line,
24 whichever is most convenient! Type either of the following
25 commands to print a file to the default (or only) printer on the
33 <H3><A NAME=
"PRINTER">Choosing a Printer
</A></H3>
35 <P>Many systems will have more than one printer available to the
36 user. These printers can be attached to the local system via a
37 parallel, serial, or USB port, or available over the network. Use
38 the
<A HREF=
"man-lpstat.html">lpstat(
1)
</A> command to see a list
39 of available printers:
</P>
45 <P>The
<CODE>-p
</CODE> option specifies that you want to see a
46 list of printers, and the
<CODE>-d
</CODE> option reports the
47 current default printer or class.
</P>
49 <P>Use the
<CODE>-d
</CODE> option with the
<B>lp
</B> command to
50 print to a specific printer:
</P>
53 lp -d printer filename
56 <P>or the
<CODE>-P
</CODE> option with the
<B>lpr
</B> command:
</P>
59 lpr -P printer filename
62 <H3><A NAME=
"DEFAULT">Setting the Default Printer
</A></H3>
64 <P>If you normally use a particular printer, you can tell CUPS to
65 use it by default using the
<A
66 HREF=
"man-lpoptions.html">lpoptions(
1)
</A> command:
</P>
72 <H3><A NAME=
"PIPE">Printing the Output of a Program
</A></H3>
74 <P>Both the
<B>lp
</B> and
<B>lpr
</B> commands support printing
75 from the standard input:
</P>
79 program | lp -d printer
81 program | lpr -P printer
84 <P>If the program does not provide any output, then nothing will
85 be queued for printing.
</P>
87 <H3><A NAME=
"WITHOPTIONS">Specifying Printer Options
</A></H3>
89 <P>For many types of files, the default printer options may be
90 sufficient for your needs. However, there may be times when you
91 need to change the options for a particular file you are
94 <P>The
<B>lp
</B> and
<B>lpr
</B> commands allow you to pass
95 printer options using the
<CODE>-o
</CODE> option:
</P>
98 lp -o landscape -o fit-to-page -o media=A4 filename.jpg
99 lpr -o landscape -o fit-to-page -o media=A4 filename.jpg
102 <P>The available printer options vary depending on the printer.
103 The standard options are described in the
"<A
104 HREF="#OPTIONS
">Standard Printing Options</A>" section
105 below. Printer-specific options are also available and can be
106 listed using the
<B>lpoptions
</B> command:
</P>
108 <PRE CLASS=
"command">
109 lpoptions -p printer -l
112 <H3><A NAME=
"INSTANCES">Creating Saved Options
</A></H3>
114 <P>Saved options are supported in CUPS through
<em>printer
115 instances
</em>. Printer instances are, as their name implies, copies
116 of a printer that have certain options associated with them. Use the
117 <B>lpoptions
</B> command to create a printer instance:
</P>
119 <PRE CLASS=
"command">
120 lpoptions -p printer/instance -o name=value ...
123 <P>The
<CODE>-p printer/instance
</CODE> option provides the name of
124 the instance, which is always the printer name, a slash, and the
125 instance name which can contain any printable characters except
126 space and slash. The remaining options are then associated with the
127 instance instead of the main queue. For example, the following
128 command creates a duplex instance of the LaserJet queue:
</P>
130 <PRE CLASS=
"command">
131 lpoptions -p LaserJet/duplex -o sides=two-sided-long-edge
134 <P>Instances
<em>do not
</em> inherit lpoptions from the main
137 <H3><A NAME=
"COPIES">Printing Multiple Copies
</A></H3>
139 <P>Both the
<B>lp
</B> and
<B>lpr
</B> commands have options for
140 printing more than one copy of a file:
</P>
142 <PRE CLASS=
"command">
143 lp -n
<EM>num-copies
</EM> filename
144 lpr -#
<EM>num-copies
</EM> filename
147 <P>Copies are normally
<EM>not
</EM> collated for you. Use the
148 <CODE>-o Collate=True
</CODE> option to get collated copies:
</P>
150 <PRE CLASS=
"command">
151 lp -n
<EM>num-copies
</EM> -o Collate=True filename
152 lpr -#
<EM>num-copies
</EM> -o Collate=True filename
156 <H2 CLASS=
"title"><A NAME=
"CANCEL">Canceling a Print Job
</A></H2>
158 <P>The
<A HREF=
"man-cancel.html">cancel(
1)
</A> and
<A
159 HREF=
"man-lprm.html">lprm(
1)
</A> commands cancel a print job:
</P>
161 <PRE CLASS=
"command">
162 cancel
<EM>job-id
</EM>
166 <P>The
<EM>job-id
</EM> is the number that was reported to you by
167 the
<B>lp
</B> command. You can also get the job ID using the
<A
168 HREF=
"man-lpq.html">lpq(
1)
</A> or
<A
169 HREF=
"man-lpstat.html">lpstat
</A> commands:
</P>
171 <PRE CLASS=
"command">
177 <H2 CLASS=
"title"><A NAME=
"LPMOVE">Moving a Print Job
</A></H2>
179 <P>The
<A HREF=
"man-lpmove.html">lpmove(
8)
</A> command moves a print
180 job to a new printer or class:
</P>
182 <PRE CLASS=
"command">
183 lpmove
<EM>job-id
</EM> <i>destination
</i>
186 <P>The
<EM>job-id
</EM> is the number that was reported to you by
187 the
<B>lp
</B> or
<B>lpstat
</B> commands.
<i>Destination
</i> is the
188 name of a printer or class that you want to actually print the job.
190 <BLOCKQUOTE><B>Note:
</B>
192 <P>The
<B>lpmove
</B> command is located in the system command
193 directory (typically
<VAR>/usr/sbin
</VAR> or
<VAR>/usr/local/sbin
</VAR>),
194 and so may not be in your command path. Specify the full path to the
195 command if you get a
"command not found" error, for example:
197 <PRE CLASS=
"command">
198 /usr/sbin/lpmove foo-
123 bar
204 <H2 CLASS=
"title"><A NAME=
"OPTIONS">Standard Printing Options
</A></H2>
206 <P>The following options apply when printing all types of
209 <H3><A NAME=
"MEDIA">Selecting the Media Size, Type, and Source
</A></H3>
211 <P>The
<CODE>-o media=xyz
</CODE> option sets the media size,
212 type, and/or source:
</P>
214 <PRE CLASS=
"command">
215 lp -o media=Letter filename
216 lp -o media=Letter,MultiPurpose filename
217 lpr -o media=Letter,Transparency filename
218 lpr -o media=Letter,MultiPurpose,Transparency filename
221 <P>The available media sizes, types, and sources depend on the
222 printer, but most support the following options (case is not
227 <LI><CODE>Letter
</CODE> - US Letter (
8.5x11 inches, or
216x279mm)
229 <LI><CODE>Legal
</CODE> - US Legal (
8.5x14 inches, or
216x356mm)
231 <LI><CODE>A4
</CODE> - ISO A4 (
8.27x11.69 inches, or
210x297mm)
233 <LI><CODE>COM10
</CODE> - US #
10 Envelope (
9.5x4.125 inches, or
236 <LI><CODE>DL
</CODE> - ISO DL Envelope (
8.66x4.33 inches, or
220x110mm)
238 <LI><CODE>Transparency
</CODE> - Transparency media type or source
240 <LI><CODE>Upper
</CODE> - Upper paper tray
242 <LI><CODE>Lower
</CODE> - Lower paper tray
244 <LI><CODE>MultiPurpose
</CODE> - Multi-purpose paper tray
246 <LI><CODE>LargeCapacity
</CODE> - Large capacity paper tray
250 <P>The actual options supported are defined in the printer's PPD
251 file in the
<CODE>PageSize
</CODE>,
<CODE>InputSlot
</CODE>, and
252 <CODE>MediaType
</CODE> options. You can list them using the
253 <B>lpoptions(
1)
</B> command:
</P>
255 <PRE CLASS=
"command">
256 lpoptions -p printer -l
259 <P>When
<CODE>Custom
</CODE> is listed for the
<CODE>PageSize
</CODE> option, you can specify custom media sizes using one of the following forms:
</P>
261 <PRE CLASS=
"command">
262 lp -o media=Custom.
<EM>WIDTH
</EM>x
<EM>LENGTH
</EM> filename
263 lp -o media=Custom.
<EM>WIDTH
</EM>x
<EM>LENGTH
</EM>in filename
264 lp -o media=Custom.
<EM>WIDTH
</EM>x
<EM>LENGTH
</EM>cm filename
265 lp -o media=Custom.
<EM>WIDTH
</EM>x
<EM>LENGTH
</EM>mm filename
268 <P>where
"WIDTH" and
"LENGTH" are the width and length of the media in points, inches, centimeters, or millimeters, respectively.
</P>
271 <H3><A NAME=
"ORIENTATION">Setting the Orientation
</A></H3>
273 <P>The
<CODE>-o landscape
</CODE> option will rotate the page
90
274 degrees to print in landscape orientation:
</P>
276 <PRE CLASS=
"command">
277 lp -o landscape filename
278 lpr -o landscape filename
281 <P>The
<CODE>-o orientation-requested=N
</CODE> option rotates the
282 page depending on the value of N:
</P>
286 <LI><CODE>-o orientation-requested=
3</CODE> - portrait
287 orientation (no rotation)
</LI>
289 <LI><CODE>-o orientation-requested=
4</CODE> - landscape
290 orientation (
90 degrees)
</LI>
292 <LI><CODE>-o orientation-requested=
5</CODE> - reverse
293 landscape or seascape orientation (
270 degrees)
</LI>
295 <LI><CODE>-o orientation-requested=
6</CODE> - reverse
296 portrait or upside-down orientation (
180 degrees)
</LI>
301 <H3><A NAME=
"SIDES">Printing On Both Sides of the Paper
</A></H3>
303 <P>The
<CODE>-o sides=two-sided-short-edge
</CODE> and
<CODE>-o
304 sides=two-sided-long-edge
</CODE> options will enable two-sided
305 printing on the printer if the printer supports it. The
<CODE>-o
306 sides=two-sided-short-edge
</CODE> option is suitable for
307 landscape pages, while the
<CODE>-o
308 sides=two-sided-long-edge
</CODE> option is suitable for portrait
311 <PRE CLASS=
"command">
312 lp -o sides=two-sided-short-edge filename
313 lp -o sides=two-sided-long-edge filename
314 lpr -o sides=two-sided-long-edge filename
317 <P>The default is to print single-sided:
</P>
319 <PRE CLASS=
"command">
320 lp -o sides=one-sided filename
321 lpr -o sides=one-sided filename
325 <H3><A NAME=
"JOBSHEETS">Selecting the Banner Page(s)
</A></H3>
327 <P>The
<CODE>-o job-sheets=start,end
</CODE> option sets the banner
328 page(s) to use for a job:
</P>
330 <PRE CLASS=
"command">
331 lp -o job-sheets=none filename
332 lp -o job-sheets=standard filename
333 lpr -o job-sheets=classified,classified filename
336 <P>If only one banner file is specified, it will be printed
337 before the files in the job. If a second banner file is
338 specified, it is printed after the files in the job.
</P>
340 <P>The available banner pages depend on the local system
341 configuration; CUPS includes the following banner files:
</P>
345 <LI><CODE>none
</CODE> - Do not produce a banner page.
347 <LI><CODE>classified
</CODE> - A banner page with a
"classified"
348 label at the top and bottom.
350 <LI><CODE>confidential
</CODE> - A banner page with a
351 "confidential" label at the top and bottom.
353 <LI><CODE>secret
</CODE> - A banner page with a
"secret" label
354 at the top and bottom.
356 <LI><CODE>standard
</CODE> - A banner page with no label at the
359 <LI><CODE>topsecret
</CODE> - A banner page with a
"top secret"
360 label at the top and bottom.
362 <LI><CODE>unclassified
</CODE> - A banner page with an
363 "unclassified" label at the top and bottom.
368 <H3><A NAME=
"JOBHOLDUNTIL">Holding Jobs for Later Printing
</A></H3>
370 <P>The
<CODE>-o job-hold-until=when
</CODE> option tells CUPS to
371 delay printing until the
"when" time, which can be one of the
376 <LI><CODE>-o job-hold-until=indefinite
</CODE>; print only
377 after released by the user or an administrator
</LI>
379 <LI><CODE>-o job-hold-until=day-time
</CODE>; print from
380 6am to
6pm local time
</LI>
382 <LI><CODE>-o job-hold-until=night
</CODE>; print from
383 6pm to
6am local time
</LI>
385 <LI><CODE>-o job-hold-until=second-shift
</CODE>; print from
386 4pm to
12am local time
</LI>
388 <LI><CODE>-o job-hold-until=third-shift
</CODE>; print from
389 12am to
8am local time
</LI>
391 <LI><CODE>-o job-hold-until=weekend
</CODE>; print on Saturday
394 <LI><CODE>-o job-hold-until=HH:MM
</CODE>; print at the specified
399 <H3><A NAME=
"RELEASEJOB">Releasing Held Jobs
</A></H3>
401 <P>Aside from the web interface, you can use the
<B>lp
</B> command
402 to release a held job:
</P>
404 <PRE CLASS=
"command">
405 lp -i
<em>job-id
</em> -H resume
408 <P>where
"job-id" is the job ID reported by the
<B>lpstat
</B>
412 <H3><A NAME=
"JOBPRIORITY">Setting the Job Priority
</A></H3>
414 <P>The
<CODE>-o job-priority=NNN
</CODE> option tells CUPS to
415 assign a priority to your job from
1 (lowest) to
100 (highest),
416 which influences where the job appears in the print queue. Higher
417 priority jobs are printed before lower priority jobs, however
418 submitting a new job with a high priority will not interrupt an
419 already printing job.
</P>
422 <H3><A NAME=
"OUTPUTORDER">Specifying the Output Order
</A></H3>
424 <P>The
<CODE>-o outputorder=normal
</CODE> and
<CODE>-o outputorder=reverse
</CODE> options specify the order of the pages. Normal order prints page
1 first, page
2 second, and so forth. Reverse order prints page
1 last.
</P>
427 <H3><A NAME=
"PAGERANGES">Selecting a Range of Pages
</A></H3>
429 <P>The
<CODE>-o page-ranges=pages
</CODE> option selects a range
430 of pages for printing:
</P>
432 <PRE CLASS=
"command">
433 lp -o page-ranges=
1 filename
434 lp -o page-ranges=
1-
4 filename
435 lp -o page-ranges=
1-
4,
7,
9-
12 filename
436 lpr -o page-ranges=
1-
4,
7,
9-
12 filename
439 <P>As shown above, the
<CODE>pages
</CODE> value can be a single page, a
440 range of pages, or a collection of page numbers and ranges separated by
441 commas. The pages will always be printed in ascending order, regardless
442 of the order of the pages in the
<CODE>page-ranges
</CODE> option.
444 <P>The default is to print all pages.
446 <blockquote><b>Note:
</b>
448 <p>The page numbers used by
<code>page-ranges
</code> refer to the output
449 pages and not the document's page numbers. Options like
<code>number-up
</code>
450 can make the output page numbering not match the document page numbers.
</p>
455 <H3><A NAME=
"PAGESET">Selecting Even or Odd Pages
</A></H3>
457 <P>Use the
<CODE>-o page-set=set
</CODE> option to select the even or odd pages:
</P>
459 <PRE CLASS=
"command">
460 lp -o page-set=odd filename
461 lp -o page-set=even filename
462 lpr -o page-set=even filename
465 <P>The default is to print all pages.
467 <H3><A NAME=
"NUMBERUP">N-Up Printing
</A></H3>
469 <P>The
<CODE>-o number-up=value
</CODE> option selects N-Up
470 printing. N-Up printing places multiple document pages on a
471 single printed page. CUPS supports
1,
2,
4,
6,
9, and
16-Up
472 formats; the default format is
1-Up:
</P>
474 <PRE CLASS=
"command">
475 lp -o number-up=
1 filename
476 lp -o number-up=
2 filename
477 lp -o number-up=
4 filename
478 lpr -o number-up=
16 filename
481 <P>The
<CODE>-o page-border=value
</CODE> option chooses the
482 border to draw around each page:
</P>
485 <LI><CODE>-o page-border=double
</CODE>; draw two hairline borders around each page
</LI>
486 <LI><CODE>-o page-border=double-thick
</CODE>; draw two
1pt borders around each page
</LI>
487 <LI><CODE>-o page-border=none
</CODE>; do not draw a border (default)
</LI>
488 <LI><CODE>-o page-border=single
</CODE>; draw one hairline border around each page
</LI>
489 <LI><CODE>-o page-border=single-thick
</CODE>; draw one
1pt border around each page
</LI>
492 <P>The
<CODE>-o number-up-layout=value
</CODE> option chooses the
493 layout of the pages on each output page:
</P>
496 <LI><CODE>-o number-up-layout=btlr
</CODE>; Bottom to top, left to right
</LI>
497 <LI><CODE>-o number-up-layout=btrl
</CODE>; Bottom to top, right to left
</LI>
498 <LI><CODE>-o number-up-layout=lrbt
</CODE>; Left to right, bottom to top
</LI>
499 <LI><CODE>-o number-up-layout=lrtb
</CODE>; Left to right, top to bottom (default)
</LI>
500 <LI><CODE>-o number-up-layout=rlbt
</CODE>; Right to left, bottom to top
</LI>
501 <LI><CODE>-o number-up-layout=rltb
</CODE>; Right to left, top to bottom
</LI>
502 <LI><CODE>-o number-up-layout=tblr
</CODE>; Top to bottom, left to right
</LI>
503 <LI><CODE>-o number-up-layout=tbrl
</CODE>; Top to bottom, right to left
</LI>
506 <H3><A NAME=
"FIT_TO_PAGE">Scaling to Fit
</A></H3>
508 <P>The
<CODE>-o fit-to-page
</CODE> option specifies that the document
509 should be scaled to fit on the page:
</P>
511 <PRE CLASS=
"command">
512 lp -o fit-to-page filename
513 lpr -o fit-to-page filename
516 <P>The default is to use the size specified in the file.
</P>
518 <BLOCKQUOTE><B>Note:
</B>
520 <P>This feature depends upon an accurate size in
521 the print file. If no size is given in the file, the page may be
526 <H3><A NAME=
"OUTPUTORDER">Printing in Reverse Order
</A></H3>
528 <P>The
<CODE>-o outputorder=reverse
</CODE> option will print the
529 pages in reverse order:
</P>
531 <PRE CLASS=
"command">
532 lp -o outputorder=reverse filename
533 lpr -o outputorder=reverse filename
536 <P>Similarly, the
<CODE>-o outputorder=normal
</CODE> option will
537 print starting with page
1:
</P>
539 <PRE CLASS=
"command">
540 lp -o outputorder=normal filename
541 lpr -o outputorder=normal filename
544 <P>The default is
<CODE>-o outputorder=normal
</CODE> for
545 printers that print face down and
<CODE>-o outputorder=reverse
</CODE>
546 for printers that print face up.
548 <H3><A NAME=
"MIRROR">Printing Mirrored Pages
</A></H3>
550 <P>The
<CODE>-o mirror
</CODE> option flips each page along the
551 vertical axis to produce a mirrored image:
</P>
553 <PRE CLASS=
"command">
554 lp -o mirror filename
555 lpr -o mirror filename
558 <P>This is typically used when printing on T-shirt transfer
559 media or sometimes on transparencies.
</P>
561 <H3><A NAME=
"RAW">Raw or Unfiltered Output
</A></H3>
563 <P>The
<CODE>-o raw
</CODE> option allows you to send files
564 directly to a printer without filtering. This is sometimes
565 required when printing from applications that provide their own
566 "printer drivers" for your printer:
</P>
568 <PRE CLASS=
"command">
573 <P>The
<CODE>-l
</CODE> option can also be used with the
574 <B>lpr
</B> command to send files directly to a printer:
</P>
576 <PRE CLASS=
"command">
581 <H2 CLASS=
"title"><A NAME=
"TEXTOPTIONS">Text Options
</A></H2>
583 <P>CUPS supports several options that are only used when printing
584 plain text files. These options have absolutely no effect on
585 PostScript, PDF, HP-GL/
2, or image files.
</P>
587 <H3><A NAME=
"CPI">Setting the Number of Characters Per Inch
</A></H3>
589 <P>The
<CODE>-o cpi=value
</CODE> option sets the number of
590 characters per inch:
</P>
592 <PRE CLASS=
"command">
593 lp -o cpi=
10 filename
594 lp -o cpi=
12 filename
595 lpr -o cpi=
17 filename
598 <P>The default characters per inch is
10.
</P>
600 <H3><A NAME=
"LPI">Setting the Number of Lines Per Inch
</A></H3>
602 <P>The
<CODE>-o lpi=value
</CODE> option sets the number of lines
605 <PRE CLASS=
"command">
607 lpr -o lpi=
8 filename
610 <P>The default lines per inch is
6.
</P>
612 <H3><A NAME=
"COLUMNS">Setting the Number of Columns
</A></H3>
614 <P>The
<CODE>-o columns=value
</CODE> option sets the number of
617 <PRE CLASS=
"command">
618 lp -o columns=
2 filename
619 lpr -o columns=
3 filename
622 <P>The default number of columns is
1.
</P>
624 <H3><A NAME=
"MARGINS">Setting the Page Margins
</A></H3>
626 <P>Normally the page margins are set to the hard limits of the
627 printer. Use the
<CODE>-o page-left=value
</CODE>,
<CODE>-o
628 page-right=value
</CODE>,
<CODE>-o page-top=value
</CODE>, and
629 <CODE>-o page-bottom=value
</CODE> options to adjust the page
632 <PRE CLASS=
"command">
633 lp -o page-left=
<EM>value
</EM> filename
634 lp -o page-right=
<EM>value
</EM> filename
635 lp -o page-top=
<EM>value
</EM> filename
636 lp -o page-bottom=
<EM>value
</EM> filename
637 lpr -o page-left=
<EM>value
</EM> -o page-right=
<EM>value
</EM> -o page-top=
<EM>value
</EM> -o page-bottom=
<EM>value
</EM> filename
640 <P>The
<CODE>value
</CODE> argument is the margin in points; each
641 point is
1/
72 inch or
0.35mm.
</P>
643 <H3><A NAME=
"PRETTYPRINT">Pretty Printing
</A></H3>
645 <P>The
<CODE>-o prettyprint
</CODE> option puts a header at the
646 top of each page with the page number, job title (usually the
647 filename), and the date. Also, C and C++ keywords are
648 highlighted, and comment lines are italicized:
</P>
650 <PRE CLASS=
"command">
651 lp -o prettyprint filename
652 lpr -o prettyprint filename
655 <H3><A NAME=
"WRAP">Turning Off Text Wrapping
</A></H3>
657 <P>The
<CODE>-o nowrap
</CODE> option disables wrapping of long lines:
</P>
659 <PRE CLASS=
"command">
660 lp -o nowrap filename
661 lpr -o nowrap filename