PRINTING WITH A2PS

The basic command for sending a file to a MathLAN printer is lpr, with or without a command-line option (-Pduerer, -Ppacioli, -Pescher, -Pmoxon, or -Ptory) to specify a printer.

However, the lpr program is rather limited. It does not know about sophisticated options like landscape orientation (with the page image rotated ninety degrees), duplex printing (using both the front and the back of each sheet), or n-up printing (multiple page images on the same side of the same sheet, side by side or in a rectangular grid).

To achieve these subtler effects, we need a print filter -- a program that applies a transformation to the print job and sends the result to the printer (through lpr, although the actual invocation of lpr is usually invisible). This guide discusses a few of the features of a program called a2ps, which acts as an interface to a large selection of filters.

Invoking a2ps

One common way to run a2ps is from a shell (in a terminal emulator). At the shell prompt, type its name and the name of a file that you want it to transform, thus:

a2ps frogs.dvi

By looking at the name of the file and the first few bytes of its contents, a2ps can usually determine what kind of a file it is. For instance, it detects that frogs.dvi is a device-independent file constructed by TEX or LATEX, and it therefore runs a DVI-to-PostScript translator on the file before sending it to one of our PostScript printers. Similarly, it will run a file containing Java source code through a Java pretty-printer that italicizes comments and boldfaces keywords automatically, convert a JPEG image file to PostScript, and automatically expand a compressed (.gz) file.

Command-line options

By default, a2ps produces single-sided sheets in portrait orientation; if the file being printed is a text file, a2ps draws a border around the body of each page and adds a header and a footer, giving the name and last-modification date of the file, the name of the person who printed it, the date of the print job, and a page number.

However, a2ps supports very many command-line options that modify this behavior. This document deals only with a few particularly useful ones; for a full list, type

a2ps --help

in a shell window, or consult Section 3.1 of the reference manual, ``General purpose PostScript generating utility.''

--silent
suppress the usual a2ps output (a report of which transformers it is applying, followed by a page count)
--user-option=lp
imitate a line printer (turn off borders, headers, etc.)
--landscape
print in landscape orientation
-2
print two page images on each physical page, side by side (in landscape orientation); -3, -4, -6, and even -9 work similarly (magnifying glasses sold separately)
--borders=no
turn off borders around text bodies
--font-size=10
use ten-point fonts
--no-header
turn off headers and footers
--pages=3-7
print only pages 3 through 7 of the document
--interpret=yes
treat control-I characters (tabs) as tabs and control-L characters as form feeds
--pretty-print=scheme
apply the Scheme pretty-printing conventions to transform this file. (This is useful if the file name ends in .ss, since a2ps does not recognize such files as Scheme source code -- it prefers .scm.)
--output=frogs.ps
put the result of the transformations into the file frogs.ps instead of sending it to the printer
--printer=escher
send the file to escher rather than to the default printer (duerer, pacioli, moxon, or tory can be substituted for escher)
--copies=3
make three copies of each page
--sides=duplex
use both sides of each sheet

a2ps as a print command in other programs

Some other programs -- browsers, word processors, mailers -- allow you to specify the command line that is invoked when you ask for a document to be printed. Most of them make lpr the default, but it is often possible to ask for a2ps, with or without command-line options, instead.

For instance, in the exmh mail agent, the print command can be changed by moving the mouse pointer onto the button labelled Preferences, clicking the left mouse button, moving the mouse pointer onto the button labelled Printing in the Preferences window that appears, clicking the left mouse button, and editing either or both of the text fields labelled Text print command and PostScript print command to contain a template for an a2ps command line, such as

a2ps --silent --sides=duplex $file

Similarly, when printing from Netscape, you can use

a2ps --silent --sides=duplex

as your print command (in this case, the name of a temporary file containing the document is just assumed to go at the end).

The AbiWord word processor does not appear to recognize a2ps as a print command, however.

DrScheme has an internal pretty-printer that generates PostScript already (so the --pretty-print=scheme option is counter-productive in this case -- it causes the PostScript page description to be pretty-printed as if it were a Scheme program). You might nevertheless want to change the print command to a2ps, to take advantage of some of the other options. In DrScheme's PostScript window, edit the text field labelled Printer Command: to contain a2ps and the one labelled Print Options: to contain, say, -2 --silent --borders=no.

(laurel leaf logo)

created August 8, 2000
last revised June 26, 2001

John David Stone (stone@cs.grinnell.edu)