Printing tips and techniques
Reviewed by Murray Anderegg 02/27/2013
This article describes various printing tips and techniques that were sent in by the users of this department. Further suggestions can be mailed to email@example.com. Computer Services does not guarantee that all tips/techniques will work. Linux users wishing to configure complex printing options under GNOME or KDE may wish to consider using the document viewer application for their environment. The GNOME document viewer is ‘evince’. The document viewers can usually handle PDF files.
When printing with the ‘lpr’ or ‘lp’ commands, append the desired option for the number of sides, e.g.
lpr -Pljsn266d -o sides=one-sided /etc/ntp.conf
lp -dljsn266d -o sides=one-sided /etc/ntp.conf
lpr -Pljsn266d -o sides=two-sided-long-edge /etc/ntp.conf
lp -dljsn266d -o sides=two-sided-long-edge /etc/ntp.conf
All of the public HP LaserJet printers are duplex capable and have duplexing enabled by default.
When printing from the Linux document viewer, evince, there is a large palette of selectable options including duplex under the ‘Page Setup’ tab.
First convert a (La)TeX file to a DVI file:
This processes file.tex (optional .tex suffix) and writes to file.dvi. Second, convert the dvi file to a pdv file:
dvipdf -o file.pdf file[.dvi]
This converts dvi file to pdf and writes to specified file file.pdf. Then print the pdf file:
lpr -Pprintername file.pdf
xdvi displays dvi files. evince (Document Viewer) displays pdf and ps (PostScript) files in the GNOME desktop environment. dvi files can be converted to pdf and PostScript (see above) and viewed via evince. This is especially convenient when you have PostScript included in your dvi file. (xdvi doesn’t display included PostScript.)
evince is useful for previewing and/or printing the whole document or individual pages. Since certain features of LaTeX don’t consistently work properly, please preview LaTeX-produced documents.
When debugging custom postscript try to do as much as possible with a previewer, but sometimes there are differences between evince and the real adobe implementations.
evince is available on the command-line. evince is also the default application when a .pdf or a .ps file is clicked on in the nautilus file manager in the GNOME desktop environment.
Printing 2 pages of ASCII text on a single sheet:
enscript -2r <filename>
Or, to receive a fancier file header on each page,
enscript -2rG <filename>
The ‘pstops’ program may be used to do almost any kind of rearranging of standard postscript documents, given the right arguments. Unfortunately, figuring out the proper arguments can be quite a challenge. Here are some easy answers.
Note that pstops operates as a unix filter, and thus it accepts the document to be formated as standard input and outputs the rearranged document as standard output. It also lets you specify an input file, and, if given an input file, it lets you specify an output file as well.
Landscape mode: We assume that the pages are already formated for portrait mode, so just turning them sideways would be pointless, unless you wanted to put two per page. The incantation for doing this is:
Supposing you wanted to print 4 per page, it’s:
To print a PostScript file two pages on one, use:
pstops ‘2:0L@.7(8.3in,-.2in)+1L@.7(8.3in,4.9in)’ FILE.ps | lpr -P<printer_name>
This prints two pages on one in landscape mode.
To reverse the page order of a document (This is useful when printing a document formated for a printer whose pages come out face up on a printer whose pages come out face down.):
To print a ps file that has been formated for A4 paper on letter-size paper, use the following:
pstops ‘(0,-1.3cm)’ FILE.ps | lpr -P$LASER
This shifts the text down a bit, so that there is a little more room at the top of the page.
To select a certain range of pages to be printed, use:
Where “S” and “E” are the starting and ending page numbers. Either may be omitted, and the first and last pages will be assumed, respectively.
To capture a copy of a window under X Windows or the GNOME or KDE desktop environments, use the xwd utility. xwd grabs the focus from the window manager, and presents a cross-shaped cursor to the user. xwd will then capture or dump the next window, in which the mouse is clicked. By default, the screen capture is sent in binary output to the standard output of the terminal, in which the command was executed. xwd provides the -out <filename> option to redirect the output to <filename>. For example,
xwd -out my-terminal.xwd
xwd saves its output in XWD (X Window Dump) image data format. The mogrify utility can be used to convert the data format to a more common format such as JPEG:
mogrify -format jpg my-terminal.xwd
This will create a new file my-terminal.jpg with a JPEG version of the window capture.
Occasionally files get corrupted. Therefore, preview a file before sending it to the printer.
When printing on odd sized paper (labels, etc.), use the manual feed option. Then, bring your custom paper to the printer.
For more information on printing and printers, see our other help articles on printing, and the UNIX on-line maunal pages for ‘lpr’, ‘lp’, ‘pr’, ‘enscript’, and the various DVI utilities. Online help is available from within evince.