User Tools

Site Tools


it_services:mf:printing_cmdline

Printing from command line

For a description of the printers available to Linux machines refer to printing

On the Linux system the printing is handled by a central print-spooler. The spooler queues, format (if necessary) and send the file to the printer. The spooler is in our case called cups.matfys.lth.se . In the normal case the file you want to print should be a postscript-file. All our printers understand postscript and PDF. One typical format is “text”, but even a lot of other formats is possible. The spooler takes care of the file, and try to do its best to convert it to postscript before it is sent to the printer. However, in most cases, might be required that you convert the files to postscript yourself.

To print a document “file.ps” to the default printer, use

lpr file.ps

To print to another printer (copy_n in this example) use

lpr -P copy_n file.ps

See what is in the print queue

  lpq
  lpq -P copy_t

Remove all your printouts from the queue

  lprm -
  lprm - -P printer

Duplex/simplex

Printers that are able to print duplex, do that by default, and are flipping the page along the long edge. To print in simplex (only on one side of the paper)

  lpr -o sides=one-sided file.ps

To print on both sides and flip along the short edge

  lpr -o sides=two-sided-short-edge file.ps

To print on both sides and flip along the long edge (default)

lpr -o sides=two-sided-long-edge file.ps
  lpr -o page-ranges=4 file.ps
  lpr -o page-ranges=1-8 file.ps
  lpr -o page-ranges=1,3,6 file.ps

Pretty printing

This option is only useful when printing text files.

Specifies that the file should be formatted with a shaded header with the date, time, job name, and page number.

  lpr -p file.ps

or

lpr -o prettyprint file.ps

To print two pages on each side of the paper

lpr -o number-up=2 file.ps

And to get in even more on the paper

lpr -o number-up=4 file.ps

You can also use 8 and 16. But can you read it?

Rotate

To rotate the page 90 degrees and print it in landscape orientation

lpr -o landscape file.ps

In most cases it is better to create the file in landscape orientation.

Mirroring

lpr -o mirror file.ps

Might be useful if you want to print something that Leonardo D. has written.

Combining options

You can combine the options, like in the following example

lpr -P newprinter -o prettyprint -o number-up=2 file.ps

Other useful utilities

ps2ps can do a lot of tricks on a postscript-file. It is used in the background of the printing system to handle many of the options above, but can be used directly on a file. ps2ps can sometimes be used to “clean up” ps or eps files originating from other systems.

gv or ghostview, is the number one program to check a ps-file before printing it. It can save many trees – but nowadays you're used to this.

References

it_services/mf/printing_cmdline.txt · Last modified: 2014/09/17 17:55 by florido