OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Another Option: a2ps

The a2ps program is interesting. As we can surmise from its name, it’s a format conver- sion program, but it also much more. Its name originally meant “ASCII to PostScript” and it was used to prepare text files for printing on PostScript printers. Over the years, however, the capabilities of the program have grown, and now its name means “Anything to PostScript.” While its name suggests a format-conversion program, it is actually a printing program. It sends its default output to the system’s default printer rather than standard output. The program’s default behavior is that of a “pretty printer,” meaning that it improves the appearance of output. If we use the program to create a PostScript file on our desktop:



[me@linuxbox ~]$ ls /usr/bin | pr -3 -t | a2ps -o ~/Desktop/ls.ps -L 66

[stdin (plain): 11 pages on 6 sheets]

[Total: 11 pages on 6 sheets] saved into the file `/home/me/Desktop/ ls.ps'

[me@linuxbox ~]$ ls /usr/bin | pr -3 -t | a2ps -o ~/Desktop/ls.ps -L 66

[stdin (plain): 11 pages on 6 sheets]

[Total: 11 pages on 6 sheets] saved into the file `/home/me/Desktop/ ls.ps'


Here we filter the stream with pr, using the -t option (omit headers and footers) and then with a2ps, specifying an output file (-o option) and 66 lines per page (-L option)


to match the output pagination of pr. If we view the resulting file with a suitable file viewer, we will see this:


image

Figure 6: Viewing a2ps Output


As we can see, the default output layout is “two up” format. This causes the contents of 2 pages to be printed on each sheet of paper. a2ps applies nice page headers and footers, too.

a2ps has a lot of options. Here is a summary:


Table 22-4: a2ps Options


Option Description

Option Description

--center-title=text Set center page title to text.


image

--columns=number Arrange pages into number columns. Default is 2.


image


image

--footer=text Set page footer to text.


image

--guess Report the types of files given as arguments. Since a2ps tries to convert and format all types of data, this option can be useful for predicting what a2ps will do when given a particular file.


image

--left-footer=text Set left-page footer to text.


image

--left-title=text Set left-page title to text.


image

--line-numbers=interval Number lines of output every interval lines.


image

--list=defaults Display default settings.


image

--list=topic Display settings for topic, where topic is one of the following: delegations (external programs that will be used to convert data), encodings, features, variables, media (paper sizes and the like), ppd (PostScript printer descriptions), printers, prologues (portions of code that are prefixed to normal output), stylesheets, and user options.


image

--pages=range Print pages in range.


image

--right-footer=text Set right-page footer to text.


image

--right-title=text Set right-page title to text.


image

--rows=number Arrange pages into number rows. Default is one.


image

-B No page headers.


image

-b text Set page header to text.


image

-f size Use size point font.


image

-l number Set characters per line to number. This and the

-L option (below) can be used to make files paginated with other programs, such as pr, fit correctly on the page.


image

-L number Set lines per page to number.


image

-M name Use media name. For example, “A4”.


image

-n number Output number copies of each page.


image


image

-o file Send output to file. If file is specified as “-”, use standard output.


image

-P printer Use printer. If a printer is not specified, the system default printer is used.


image

-R Portrait orientation.


image

-r Landscape orientation.


image

-T number Set tab stops to every number characters.


image

image

image

-u text Underlay (watermark) pages with text. This is just a summary. a2ps has several more options.

Note: There is another output formatter that is useful for converting text into Post- Script. Called enscript, it can perform many of the same kinds of formatting and printing tricks, but unlike a2ps, it only accepts text input.


image


Top OS Cloud Computing at OnWorks: