1<HTML>
2<!-- SECTION: Getting Started -->
3<HEAD>
4	<TITLE>Command-Line Printing and Options</TITLE>
5	<LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups-printable.css">
6</HEAD>
7<BODY>
8
9<H1 CLASS="title">Command-Line Printing and Options</H1>
10
11<P>CUPS provides both the System V (<A
12HREF="man-lp.html">lp(1)</A>) and Berkeley (<A
13HREF="man-lpr.html">lpr(1)</A>) printing commands for printing
14files. In addition, it supported a large number of standard and
15printer-specific options that allow you to control how and where
16files are printed.</P>
17
18
19<H2 CLASS="title"><A NAME="BASICS">Printing Files</A></H2>
20
21<P>CUPS understands many different types of files directly,
22including text, PostScript, PDF, and image files. This allows you
23to print from inside your applications or at the command-line,
24whichever is most convenient! Type either of the following
25commands to print a file to the default (or only) printer on the
26system:</P>
27
28<PRE CLASS="command">
29lp filename
30lpr filename
31</PRE>
32
33<H3><A NAME="PRINTER">Choosing a Printer</A></H3>
34
35<P>Many systems will have more than one printer available to the
36user. These printers can be attached to the local system via a
37parallel, serial, or USB port, or available over the network. Use
38the <A HREF="man-lpstat.html">lpstat(1)</A> command to see a list
39of available printers:</P>
40
41<PRE CLASS="command">
42lpstat -p -d
43</PRE>
44
45<P>The <CODE>-p</CODE> option specifies that you want to see a
46list of printers, and the <CODE>-d</CODE> option reports the
47current default printer or class.</P>
48
49<P>Use the <CODE>-d</CODE> option with the <B>lp</B> command to
50print to a specific printer:</P>
51
52<PRE CLASS="command">
53lp -d printer filename
54</PRE>
55
56<P>or the <CODE>-P</CODE> option with the <B>lpr</B> command:</P>
57
58<PRE CLASS="command">
59lpr -P printer filename
60</PRE>
61
62<H3><A NAME="DEFAULT">Setting the Default Printer</A></H3>
63
64<P>If you normally use a particular printer, you can tell CUPS to
65use it by default using the <A
66HREF="man-lpoptions.html">lpoptions(1)</A> command:</P>
67
68<PRE CLASS="command">
69lpoptions -d printer
70</PRE>
71
72<H3><A NAME="PIPE">Printing the Output of a Program</A></H3>
73
74<P>Both the <B>lp</B> and <B>lpr</B> commands support printing
75from the standard input:</P>
76
77<PRE CLASS="command">
78program | lp
79program | lp -d printer
80program | lpr
81program | lpr -P printer
82</PRE>
83
84<P>If the program does not provide any output, then nothing will
85be queued for printing.</P>
86
87<H3><A NAME="WITHOPTIONS">Specifying Printer Options</A></H3>
88
89<P>For many types of files, the default printer options may be
90sufficient for your needs. However, there may be times when you
91need to change the options for a particular file you are
92printing.</P>
93
94<P>The <B>lp</B> and <B>lpr</B> commands allow you to pass
95printer options using the <CODE>-o</CODE> option:</P>
96
97<PRE CLASS="command">
98lp -o landscape -o fit-to-page -o media=A4 filename.jpg
99lpr -o landscape -o fit-to-page -o media=A4 filename.jpg
100</PRE>
101
102<P>The available printer options vary depending on the printer.
103The standard options are described in the "<A
104HREF="#OPTIONS">Standard Printing Options</A>" section
105below. Printer-specific options are also available and can be
106listed using the <B>lpoptions</B> command:</P>
107
108<PRE CLASS="command">
109lpoptions -p printer -l
110</PRE>
111
112<H3><A NAME="INSTANCES">Creating Saved Options</A></H3>
113
114<P>Saved options are supported in CUPS through <em>printer
115instances</em>. Printer instances are, as their name implies, copies
116of a printer that have certain options associated with them. Use the
117<B>lpoptions</B> command to create a printer instance:</P>
118
119<PRE CLASS="command">
120lpoptions -p printer/instance -o name=value ...
121</PRE>
122
123<P>The <CODE>-p printer/instance</CODE> option provides the name of
124the instance, which is always the printer name, a slash, and the
125instance name which can contain any printable characters except
126space and slash. The remaining options are then associated with the
127instance instead of the main queue. For example, the following
128command creates a duplex instance of the LaserJet queue:</P>
129
130<PRE CLASS="command">
131lpoptions -p LaserJet/duplex -o sides=two-sided-long-edge
132</PRE>
133
134<P>Instances <em>do not</em> inherit lpoptions from the main
135queue.</P>
136
137<H3><A NAME="COPIES">Printing Multiple Copies</A></H3>
138
139<P>Both the <B>lp</B> and <B>lpr</B> commands have options for
140printing more than one copy of a file:</P>
141
142<PRE CLASS="command">
143lp -n <EM>num-copies</EM> filename
144lpr -#<EM>num-copies</EM> filename
145</PRE>
146
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>
149
150<PRE CLASS="command">
151lp -n <EM>num-copies</EM> -o Collate=True filename
152lpr -#<EM>num-copies</EM> -o Collate=True filename
153</PRE>
154
155
156<H2 CLASS="title"><A NAME="CANCEL">Canceling a Print Job</A></H2>
157
158<P>The <A HREF="man-cancel.html">cancel(1)</A> and <A
159HREF="man-lprm.html">lprm(1)</A> commands cancel a print job:</P>
160
161<PRE CLASS="command">
162cancel <EM>job-id</EM>
163lprm <EM>job-id</EM>
164</PRE>
165
166<P>The <EM>job-id</EM> is the number that was reported to you by
167the <B>lp</B> command. You can also get the job ID using the <A
168HREF="man-lpq.html">lpq(1)</A> or <A
169HREF="man-lpstat.html">lpstat</A> commands:</P>
170
171<PRE CLASS="command">
172lpq
173lpstat
174</PRE>
175
176
177<H2 CLASS="title"><A NAME="LPMOVE">Moving a Print Job</A></H2>
178
179<P>The <A HREF="man-lpmove.html">lpmove(8)</A> command moves a print
180job to a new printer or class:</P>
181
182<PRE CLASS="command">
183lpmove <EM>job-id</EM> <i>destination</i>
184</PRE>
185
186<P>The <EM>job-id</EM> is the number that was reported to you by
187the <B>lp</B> or <B>lpstat</B> commands. <i>Destination</i> is the
188name of a printer or class that you want to actually print the job.
189
190<BLOCKQUOTE><B>Note:</B>
191
192<P>The <B>lpmove</B> command is located in the system command
193directory (typically <VAR>/usr/sbin</VAR> or <VAR>/usr/local/sbin</VAR>),
194and so may not be in your command path. Specify the full path to the
195command if you get a "command not found" error, for example:
196
197<PRE CLASS="command">
198/usr/sbin/lpmove foo-123 bar
199</PRE>
200
201</BLOCKQUOTE>
202
203
204<H2 CLASS="title"><A NAME="OPTIONS">Standard Printing Options</A></H2>
205
206<P>The following options apply when printing all types of
207files.</P>
208
209<H3><A NAME="MEDIA">Selecting the Media Size, Type, and Source</A></H3>
210
211<P>The <CODE>-o media=xyz</CODE> option sets the media size,
212type, and/or source:</P>
213
214<PRE CLASS="command">
215lp -o media=Letter filename
216lp -o media=Letter,MultiPurpose filename
217lpr -o media=Letter,Transparency filename
218lpr -o media=Letter,MultiPurpose,Transparency filename
219</PRE>
220
221<P>The available media sizes, types, and sources depend on the
222printer, but most support the following options (case is not
223significant):</P>
224
225<UL>
226
227	<LI><CODE>Letter</CODE> - US Letter (8.5x11 inches, or 216x279mm)
228
229	<LI><CODE>Legal</CODE> - US Legal (8.5x14 inches, or 216x356mm)
230
231	<LI><CODE>A4</CODE> - ISO A4 (8.27x11.69 inches, or 210x297mm)
232
233	<LI><CODE>COM10</CODE> - US #10 Envelope (9.5x4.125 inches, or
234	241x105mm)
235
236	<LI><CODE>DL</CODE> - ISO DL Envelope (8.66x4.33 inches, or 220x110mm)
237
238	<LI><CODE>Transparency</CODE> - Transparency media type or source
239
240	<LI><CODE>Upper</CODE> - Upper paper tray
241
242	<LI><CODE>Lower</CODE> - Lower paper tray
243
244	<LI><CODE>MultiPurpose</CODE> - Multi-purpose paper tray
245
246	<LI><CODE>LargeCapacity</CODE> - Large capacity paper tray
247
248</UL>
249
250<P>The actual options supported are defined in the printer's PPD
251file 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>
254
255<PRE CLASS="command">
256lpoptions -p printer -l
257</PRE>
258
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>
260
261<PRE CLASS="command">
262lp -o media=Custom.<EM>WIDTH</EM>x<EM>LENGTH</EM> filename
263lp -o media=Custom.<EM>WIDTH</EM>x<EM>LENGTH</EM>in filename
264lp -o media=Custom.<EM>WIDTH</EM>x<EM>LENGTH</EM>cm filename
265lp -o media=Custom.<EM>WIDTH</EM>x<EM>LENGTH</EM>mm filename
266</PRE>
267
268<P>where "WIDTH" and "LENGTH" are the width and length of the media in points, inches, centimeters, or millimeters, respectively.</P>
269
270
271<H3><A NAME="ORIENTATION">Setting the Orientation</A></H3>
272
273<P>The <CODE>-o landscape</CODE> option will rotate the page 90
274degrees to print in landscape orientation:</P>
275
276<PRE CLASS="command">
277lp -o landscape filename
278lpr -o landscape filename
279</PRE>
280
281<P>The <CODE>-o orientation-requested=N</CODE> option rotates the
282page depending on the value of N:</P>
283
284<UL>
285
286	<LI><CODE>-o orientation-requested=3</CODE> - portrait
287	orientation (no rotation)</LI>
288
289	<LI><CODE>-o orientation-requested=4</CODE> - landscape
290	orientation (90 degrees)</LI>
291
292	<LI><CODE>-o orientation-requested=5</CODE> - reverse
293	landscape or seascape orientation (270 degrees)</LI>
294
295	<LI><CODE>-o orientation-requested=6</CODE> - reverse
296	portrait or upside-down orientation (180 degrees)</LI>
297
298</UL>
299
300
301<H3><A NAME="SIDES">Printing On Both Sides of the Paper</A></H3>
302
303<P>The <CODE>-o sides=two-sided-short-edge</CODE> and <CODE>-o
304sides=two-sided-long-edge</CODE> options will enable two-sided
305printing on the printer if the printer supports it. The <CODE>-o
306sides=two-sided-short-edge</CODE> option is suitable for
307landscape pages, while the <CODE>-o
308sides=two-sided-long-edge</CODE> option is suitable for portrait
309pages:</P>
310
311<PRE CLASS="command">
312lp -o sides=two-sided-short-edge filename
313lp -o sides=two-sided-long-edge filename
314lpr -o sides=two-sided-long-edge filename
315</PRE>
316
317<P>The default is to print single-sided:</P>
318
319<PRE CLASS="command">
320lp -o sides=one-sided filename
321lpr -o sides=one-sided filename
322</PRE>
323
324
325<H3><A NAME="JOBSHEETS">Selecting the Banner Page(s)</A></H3>
326
327<P>The <CODE>-o job-sheets=start,end</CODE> option sets the banner
328page(s) to use for a job:</P>
329
330<PRE CLASS="command">
331lp -o job-sheets=none filename
332lp -o job-sheets=standard filename
333lpr -o job-sheets=classified,classified filename
334</PRE>
335
336<P>If only one banner file is specified, it will be printed
337before the files in the job. If a second banner file is
338specified, it is printed after the files in the job.</P>
339
340<P>The available banner pages depend on the local system
341configuration; CUPS includes the following banner files:</P>
342
343<UL>
344
345	<LI><CODE>none</CODE> - Do not produce a banner page.
346
347	<LI><CODE>classified</CODE> - A banner page with a "classified"
348	label at the top and bottom.
349
350	<LI><CODE>confidential</CODE> - A banner page with a
351	"confidential" label at the top and bottom.
352
353	<LI><CODE>secret</CODE> - A banner page with a "secret" label
354	at the top and bottom.
355
356	<LI><CODE>standard</CODE> - A banner page with no label at the
357	top and bottom.
358
359	<LI><CODE>topsecret</CODE> - A banner page with a "top secret"
360	label at the top and bottom.
361
362	<LI><CODE>unclassified</CODE> - A banner page with an
363	"unclassified" label at the top and bottom.
364
365</UL>
366
367
368<H3><A NAME="JOBHOLDUNTIL">Holding Jobs for Later Printing</A></H3>
369
370<P>The <CODE>-o job-hold-until=when</CODE> option tells CUPS to
371delay printing until the "when" time, which can be one of the
372following:</P>
373
374<UL>
375
376	<LI><CODE>-o job-hold-until=indefinite</CODE>; print only
377	after released by the user or an administrator</LI>
378
379	<LI><CODE>-o job-hold-until=day-time</CODE>; print from
380	6am to 6pm local time</LI>
381
382	<LI><CODE>-o job-hold-until=night</CODE>; print from
383	6pm to 6am local time</LI>
384
385	<LI><CODE>-o job-hold-until=second-shift</CODE>; print from
386	4pm to 12am local time</LI>
387
388	<LI><CODE>-o job-hold-until=third-shift</CODE>; print from
389	12am to 8am local time</LI>
390
391	<LI><CODE>-o job-hold-until=weekend</CODE>; print on Saturday
392	or Sunday</LI>
393
394	<LI><CODE>-o job-hold-until=HH:MM</CODE>; print at the specified
395	UTC time</LI>
396
397</UL>
398
399<H3><A NAME="RELEASEJOB">Releasing Held Jobs</A></H3>
400
401<P>Aside from the web interface, you can use the <B>lp</B> command
402to release a held job:</P>
403
404<PRE CLASS="command">
405lp -i <em>job-id</em> -H resume
406</PRE>
407
408<P>where "job-id" is the job ID reported by the <B>lpstat</B>
409command.</P>
410
411
412<H3><A NAME="JOBPRIORITY">Setting the Job Priority</A></H3>
413
414<P>The <CODE>-o job-priority=NNN</CODE> option tells CUPS to
415assign a priority to your job from 1 (lowest) to 100 (highest),
416which influences where the job appears in the print queue. Higher
417priority jobs are printed before lower priority jobs, however
418submitting a new job with a high priority will not interrupt an
419already printing job.</P>
420
421
422<H3><A NAME="OUTPUTORDER">Specifying the Output Order</A></H3>
423
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>
425
426
427<H3><A NAME="PAGERANGES">Selecting a Range of Pages</A></H3>
428
429<P>The <CODE>-o page-ranges=pages</CODE> option selects a range
430of pages for printing:</P>
431
432<PRE CLASS="command">
433lp -o page-ranges=1 filename
434lp -o page-ranges=1-4 filename
435lp -o page-ranges=1-4,7,9-12 filename
436lpr -o page-ranges=1-4,7,9-12 filename
437</PRE>
438
439<P>As shown above, the <CODE>pages</CODE> value can be a single page, a
440range of pages, or a collection of page numbers and ranges separated by
441commas. The pages will always be printed in ascending order, regardless
442of the order of the pages in the <CODE>page-ranges</CODE> option.
443
444<P>The default is to print all pages.
445
446<blockquote><b>Note:</b>
447
448<p>The page numbers used by <code>page-ranges</code> refer to the output
449pages and not the document's page numbers. Options like <code>number-up</code>
450can make the output page numbering not match the document page numbers.</p>
451
452</blockquote>
453
454
455<H3><A NAME="PAGESET">Selecting Even or Odd Pages</A></H3>
456
457<P>Use the <CODE>-o page-set=set</CODE> option to select the even or odd pages:</P>
458
459<PRE CLASS="command">
460lp -o page-set=odd filename
461lp -o page-set=even filename
462lpr -o page-set=even filename
463</PRE>
464
465<P>The default is to print all pages.
466
467<H3><A NAME="NUMBERUP">N-Up Printing</A></H3>
468
469<P>The <CODE>-o number-up=value</CODE> option selects N-Up
470printing. N-Up printing places multiple document pages on a
471single printed page. CUPS supports 1, 2, 4, 6, 9, and 16-Up
472formats; the default format is 1-Up:</P>
473
474<PRE CLASS="command">
475lp -o number-up=1 filename
476lp -o number-up=2 filename
477lp -o number-up=4 filename
478lpr -o number-up=16 filename
479</PRE>
480
481<P>The <CODE>-o page-border=value</CODE> option chooses the
482border to draw around each page:</P>
483
484<UL>
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>
490</UL>
491
492<P>The <CODE>-o number-up-layout=value</CODE> option chooses the
493layout of the pages on each output page:</P>
494
495<UL>
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>
504</UL>
505
506<H3><A NAME="FIT_TO_PAGE">Scaling to Fit</A></H3>
507
508<P>The <CODE>-o fit-to-page</CODE> option specifies that the document
509should be scaled to fit on the page:</P>
510
511<PRE CLASS="command">
512lp -o fit-to-page filename
513lpr -o fit-to-page filename
514</PRE>
515
516<P>The default is to use the size specified in the file.</P>
517
518<BLOCKQUOTE><B>Note:</B>
519
520<P>This feature depends upon an accurate size in
521the print file. If no size is given in the file, the page may be
522scaled incorrectly!
523
524</BLOCKQUOTE>
525
526<H3><A NAME="OUTPUTORDER">Printing in Reverse Order</A></H3>
527
528<P>The <CODE>-o outputorder=reverse</CODE> option will print the
529pages in reverse order:</P>
530
531<PRE CLASS="command">
532lp -o outputorder=reverse filename
533lpr -o outputorder=reverse filename
534</PRE>
535
536<P>Similarly, the <CODE>-o outputorder=normal</CODE> option will
537print starting with page 1:</P>
538
539<PRE CLASS="command">
540lp -o outputorder=normal filename
541lpr -o outputorder=normal filename
542</PRE>
543
544<P>The default is <CODE>-o outputorder=normal</CODE> for
545printers that print face down and <CODE>-o outputorder=reverse</CODE>
546for printers that print face up.
547
548<H3><A NAME="MIRROR">Printing Mirrored Pages</A></H3>
549
550<P>The <CODE>-o mirror</CODE> option flips each page along the
551vertical axis to produce a mirrored image:</P>
552
553<PRE CLASS="command">
554lp -o mirror filename
555lpr -o mirror filename
556</PRE>
557
558<P>This is typically used when printing on T-shirt transfer
559media or sometimes on transparencies.</P>
560
561<H3><A NAME="RAW">Raw or Unfiltered Output</A></H3>
562
563<P>The <CODE>-o raw</CODE> option allows you to send files
564directly to a printer without filtering. This is sometimes
565required when printing from applications that provide their own
566"printer drivers" for your printer:</P>
567
568<PRE CLASS="command">
569lp -o raw filename
570lpr -o raw filename
571</PRE>
572
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>
575
576<PRE CLASS="command">
577lpr -l filename
578</PRE>
579
580
581<H2 CLASS="title"><A NAME="TEXTOPTIONS">Text Options</A></H2>
582
583<P>CUPS supports several options that are only used when printing
584plain text files. These options have absolutely no effect on
585PostScript, PDF, HP-GL/2, or image files.</P>
586
587<H3><A NAME="CPI">Setting the Number of Characters Per Inch</A></H3>
588
589<P>The <CODE>-o cpi=value</CODE> option sets the number of
590characters per inch:</P>
591
592<PRE CLASS="command">
593lp -o cpi=10 filename
594lp -o cpi=12 filename
595lpr -o cpi=17 filename
596</PRE>
597
598<P>The default characters per inch is 10.</P>
599
600<H3><A NAME="LPI">Setting the Number of Lines Per Inch</A></H3>
601
602<P>The <CODE>-o lpi=value</CODE> option sets the number of lines
603per inch:</P>
604
605<PRE CLASS="command">
606lp -o lpi=6 filename
607lpr -o lpi=8 filename
608</PRE>
609
610<P>The default lines per inch is 6.</P>
611
612<H3><A NAME="MARGINS">Setting the Page Margins</A></H3>
613
614<P>Normally the page margins are set to the hard limits of the
615printer. Use the <CODE>-o page-left=value</CODE>, <CODE>-o
616page-right=value</CODE>, <CODE>-o page-top=value</CODE>, and
617<CODE>-o page-bottom=value</CODE> options to adjust the page
618margins:</P>
619
620<PRE CLASS="command">
621lp -o page-left=<EM>value</EM> filename
622lp -o page-right=<EM>value</EM> filename
623lp -o page-top=<EM>value</EM> filename
624lp -o page-bottom=<EM>value</EM> filename
625lpr -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
626</PRE>
627
628<P>The <CODE>value</CODE> argument is the margin in points; each
629point is 1/72 inch or 0.35mm.</P>
630
631<H3><A NAME="PRETTYPRINT">Pretty Printing</A></H3>
632
633<P>The <CODE>-o prettyprint</CODE> option puts a header at the
634top of each page with the page number, job title (usually the
635filename), and the date. Also, C and C++ keywords are
636highlighted, and comment lines are italicized:</P>
637
638<PRE CLASS="command">
639lp -o prettyprint filename
640lpr -o prettyprint filename
641</PRE>
642
643<H3><A NAME="WRAP">Turning Off Text Wrapping</A></H3>
644
645<P>The <CODE>-o nowrap</CODE> option disables wrapping of long lines:</P>
646
647<PRE CLASS="command">
648lp -o nowrap filename
649lpr -o nowrap filename
650</PRE>
651
652
653</BODY>
654</HTML>
655