Printing from the Command Line

After printing is set up, you can print various types of files from the command line. The basic command to print a file is Ipr (or Ip — they are essentially equivalent, but there are two commands for historical reasons):


The preceding command prints the postscript file to the default printer.

If more than one printer is available, use a command such as this:

lpr -P laserjet4l

The file is interpreted as a PostScript file and rendered correctly on the page. In the same way, you can print other standard file types directly from the command line because appropriate filters to convert them are included in the print system. For example, the following commands will all work (assuming the files really are in the formats suggested by their filenames):

lpr bible.pdf lpr bible.png lpr bible.jpg lpr bible.html

In the case of PostScript and PDF files, this method is entirely safe and will always produce the desired result. Other file types might sometimes be detected incorrectly. In that case, there is a risk that it might try to render the result as plain text on the paper, which is not what you want. In general for HTML and graphics file types, it makes more sense to open them in a screen viewer first (Konqueror or GIMP, for example) and then print using that application's print dialog box. This usually gives you some additional control over the appearance of the final printed copy in any case.

Was this article helpful?

0 0

Post a comment