A2PS(1L)

NAME
a2ps - formats an ascii file for printing on a postscript printer

SYNOPSIS
a2ps [ global options ] [ positional options ] [ file1 [ positional options ] ] file2 ... ] ] SH DESCRIPTION a2ps formats each named file for printing in a postscript printer; if no file is given, a2ps reads from the standard input. The output is sent to the printer or to stdout or to a file. The format used is nice and compact: normally two pages on each physical page, borders surrounding pages, headers with useful information (page number, printing date, file name or supplied header), line numbering, pretty-printing, symbol substitution etc. This is very useful for making archive listings of programs.

  Global options
Global options offered by a2ps are the following:

-? -h
    Print usage information.

-8  Print non ascii characters (with the high bit set) as ISO Latin 1 characters. (default: see -V).

-a  Use alternative paper size. In general defined to be US letter. (see -V).

-b  Force printing binary files. By default, binary files printing is stopped before second page (see -nb option).

-c  Compact mode for a sequence of files. This option allows the printing of two files in the same physical page: last page of the first file in the left (or up) side and first page of the second file in the right (or down) side. This option is valid only for twin-page mode (two pages per physical page).

-f  Fold lines too large to be printed inside the borders (default option). Max line size depends on format and font size used and whether line numbering has been suppressed.

-G  Don't print files, but write the language option -k would have guessed for them.

-h  Print usage information and exit.

-Ifile
    Use the specified file as the postscript prologue for a2ps.

-na Don't use alternative paper dimensions. In general corresponds to a4 paper. (see -V for values).

-nb Don't print binary files (default option). To detect such a file we make use of a very simple heuristic: if the first page of the file contains at less 75% of non-printing characters, it's a binary file. First page is always printed.

-nc Don't use compact mode for a sequence of files. The beginning of each file will be printed in a new physical page.

-nf Truncate lines too large (don't fold).

-nP Send output to stdout. (default: see -V).

-nr Sheet numbering (see -r option) must be continue for all files (don't reset on new file). Default option.

-nv Replace non-printing characters by a space.

-n8 Don't print non ascii characters as ISO Latin 1 characters: these characters are printed as M- (for meta) followed by the character of the low 7 bits (see -8 option).

-o -ofilename
    Save the postscript into a file. Use the file filename if specified, a2ps.ps otherwise. (default: postscript is sent to stdout).

-P -Pprinter
    Send the result to the default printer or to printer if specified. Depending on your installation, it may not be available. This option cannot follow option -o. (default: see -V).

-q  Print files in quiet mode (no summary).

-r  Reset sheet numbering for each new file. Sheet numbering is used to number physical pages (sheets) as they are printed. Page numbering numbers the logical pages, of which there are usually two per physical page (i.e. unless -p or -w is specified).

-s1 Print output in one-sided mode (only one side of each sheet). (default: see -V).

-s2 Print output in two-sided mode (front and backside of each sheet). (default: see -V).

-tnum
    Set TAB size to num (default 8). This option is ignored if -ni is specified (see below).

-v  Replace non-printing characters so that they are visible and easy to identify (default option). Control characters (ascii codes lower than 0x20) are printed like ^X for ctrl-x; the delete character (hex 0x3f) is printed as ^?. Non ascii characters (with the high bit set) are printed as M- (for meta) followed by the character of the low 7 bits. TAB, BS and FF are handled like non-printing characters if -ni option was taken.

-V  Print version and installation dependent configuration information, and exit.

-W -Wlang
    Generate a report about all the styles a2ps knows, and exit. If lang is given, just lang-style is reported.

  Positional options
Positional options are applied to all files that will be found in the rest of the command line. The -H option is the only exception: it is applied only to the next file. Positional options offered by a2ps are the following:

-1  Print only one page per physical page (single page mode).

-2  Print two pages per physical page (twin-page mode), side by side or up-down, depending on the printing mode (landscape or portrait).

-#num
    To get multiple copies of output, where num is the number of copies desired of each file named. By default, you get only one copy.

-B  Print using bold font.

-d  Print the current date and time at the bottom of the page. This option is affected by the no surrounding border and the no header options.

-Fnum
    Changes font size to this value. Default values for font size are 6.8 in landscape mode, 6.4 in twin-page portrait mode and 9.0 in single page portrait mode. Try other sizes if you think that these values are too small (or big).

-H -Htext
    Print a page header with the file name. If text is given use it instead of the file name in the page headers for printing next (and only next) file. Additional -H directives can be mixed in with the filenames.

-i  Interpret TAB, BS and FF characters (default option). TAB is replaced by enough spaces to reach next tab stop while BS and FF have their meanings.

-k -klanguage
    Enable pretty printing. If no argument is given, the style is automatically selected upon the files suffix. (default: see -V). If language is specified, used the corresponding style.

-l  Print files in landscape mode (default option). This option may not be used with the -p option.

-lnum
    Set the lines per page for printing. The font size is automatically scaled up to fill in the whole page. This is useful for printing preformatted documents which have a fixed number of lines per page. The scaling of the font size will be suppressed if this option is used with option -fnum. The minimum number of lines per page is set at 40 and maximum is at 160. If a number less than 40 is supplied, scaling will be turned off and a warning message is printed on the terminal.

-L  Print user login ID in the upper right corner of the page (default option). (available for Unix systems only)

-m  Understand UNIX manual output ie: 66 lines per page, no line numbering and possible bolding and underlining sequences. The understanding of bolding and underlining is there by default even if -m is not specified.

-n  Output lines are preceded by line numbers, numbered sequentially from 1.

-nB Don't print using bold font.

-nd Don't print the current date and time in the footer (default option).

-nH Don't print page headers.

-ni Don't interpret TAB, BS and FF characters. They will be printed according to -v option.

-nk Don't pretty print files (default option).

-nn Don't number output lines (default option).

-ns Don't print page surrounding borders.

-nt Don't translate special keywords in symbols (default option).

-nu Don't print filename at bottom of page.

-nL Don't print user login ID at top of page.

-p  Print files in portrait mode (horizontal pages). The default option is to use landscape mode.

-s  Print page surrounding borders (default option).

-t  Translate special keywords in symbols. See Section Pretty printing. This option is always enabled when the processed language is prescript(4).

-u -utext
    Print the filename, centered, at the bottom of the page (default option). If text is given, use it for following pages. This is useful to leave a note about a whole set of files.

  Pretty printing
a2ps is able to use special fonts for strings, comments, and keywords, for some languages. Currently known languages are:

    ada c c++ caml(ml) claire(cl) coq-vernacular(coq) common-lisp(lsp) eiffel(e) fortran(f) java lace(ace) mailfolder(mail) modula-3(m3) o2c oberon pascal(pas) perl(pl) postscript(ps) prescript(pre) promela(pml) python(py) sather(sa) scheme(scm) sdl-88(sdl) sh tcl tk zsh

(names in parenthesis are abbreviations).

-k  Enable automatic pretty-printing. To recognize the language in which a file has been written a2ps first consults the unix command file and trusts its result unless it is "C-program" (file is often wrong on this). If file was unable to recognize the language, then the suffix of the file is examined. Automatic pretty-printing may be the default: see -V.

-klanguage
    Selects the language mode.

-nk Returns to the plain style, and disable automatic pretty-printing.

-t  Translate special keywords in symbols. a2ps is able to convert => or other special sequences in the corresponding character in the symbol font. This must be used in conjunction with the pretty-printing mode. It is always enabled for prescript.

-nt Do not convert symbols.

-W -Wlang
    a2ps generates a report about all the styles it knows (or just lang if it is given). The report is in prescript which a language close to LaTeX. It should be processed by a2ps itself:
    a2ps -W | a2ps -kpre -oreport.ps prescript has been conceived to be a good choice of language for programs that want to produce postscript without having really to deal with postscript. Since its syntax is very close to that of LaTeX, with minor corrections it can be compiled using LaTeX.

USAGE
a2ps generates postscript to its standard output. The user could redirect this output to a file, pipe it directly to a print command (like lpr), or to another filter for further processing.
a2ps file1 > file2
a2ps -p file1 | psnup -n4 | lpr
a2ps -n -c -kc main.c main.h -Plwriter
a2ps -t tcp.pr -Plwriter prescript and a2ps can be used for one-the-fly formating. For instance, one the passwd file:
ypcat passwd |
awk -F: '{print "\textbf{" $5 "} (" $1 ") \rightarrow\textit{" $7 "}"}' |
xa2ps -kpre -P

Don't forget to make sure your printer is capable of printing postscript.

This filter must be used only with text files. Avoid specially output from TeX, troff or any other such text formatters.

EXIT STATUS
The following exit values are returned:

0   a2ps terminated normally.

1   an error occured.

2   bad argument was given.

3   unknown language mode was given.

BUGS
If a2ps is often wrong on some languages, check the result returned by file, and on big mistakes (such as "lex program text" on a perl script), ask your system administrator to update the /etc/magic file.

SEE ALSO
lpr(1), file(1), gs(1), latex(1), tgrind(1), enscript(1), prescript(4).

AUTHORS
Evan Kirshenbaum (evan@csli) for the initial version.
Miguel Santana (M.Santana@frgu.bull.fr) for versions 1.0, 2.0, 3.0, 4.0, 4.1, 4.2 and 4.3.
Emmanuel Briot (emmanuel.briot@matra-com.fr) and Akim Demaille (demaille@inf.enst.fr) for versions 4.5 and 4.6.

CONTRIBUTORS
Oscar Nierstrasz (oscar@cui.uucp)
Tim Clark (T.Clark@warwick.ac.uk)
Henk Tullemans (tullemans@apolloway.prl.philips.nl)
Johan Vromans (jv@mh.nl)
Craig Stevenson (craig.r.stevenson@att.com)
John Macdonald (jmm@eci386.uucp)
Huub van de Wetering (wstahw@lso.win.tue.nl)
erikt@cs.umu.se
wstahw@lso.win.tue.nl
mai@wolfen.cc.uow.oz
Johan Garpendahl (garp@isy.liu.se)
John Interrante (interran@uluru.stanford.edu)
Larry Barbieri (lbarbieri@ll.mit.edu)
Chris Adamo (adamo@ll.mit.edu)
Basile Starynkevitch (Basile.Starynkevitch@cea.fr)
Denis Girou (Denis.Girou@idris.fr)