The PostScript Text Formatter prtpost The prtpost utility formats raw ASCII text files for printing on a PostScript printer. It is intended for users who want to print program listings without having to select an emulation (e.g., Diablo, LaserJet). By default, lines of text are displayed in 10 point Courier type at 7.2 lines per inch in portrait mode. A page header in 10 point Courier Bold displays the time and date of printing on the left, the file name centered in the middle, and the page number on the right. The header baseline is 1/2" from the top of the page, and has left and right margins of 1/2". The main body of text has a top margin 1" wide, a left margin 3/4" wide, and a bottom margin 1/2" wide. The right margin is determined by the right limit of the printer's imageable area. The user, through command line options, can alter fonts, point sizes, margins, orientation, line spacing, and several other parameters. The prtpost utility takes a single optional argument, the source file name. If no file name is given, prtpost reads from the standard input. prtpost always writes to the standard output. These properties allow it to function as a filter under UNIX and MS-DOS. The source code is written in C, and has compiled with no changes on the IBM PC and the Sun 3. The prtpost utility reads command line options in standard UNIX style: options come between the command name and the file argument, and each option is a one or two letter code preceded by a "-". If an option takes an argument, it may immediately follow the option code or be separated from it by a space. For example, prtpost -L -P120 -F Helvetica stuff.txt means "print file stuff.txt in landscape mode and in 12 point Helvetica type." The option codes are cryptic and there is a distressingly large number of them, but they offer the user a high degree of control over the printed output. Most users use only a few of the options, and script or batch files can be written for frequently used option combinations. Since prtpost writes to standard output, redirection must be used to get a printout. For example, one might use for UNIX prtpost textfile | lpr or for DOS prtpost textfile>PRN: Margins and point sizes are specified in decipoints, where one decipoint is 1/720th of an inch. For point sizes, this amounts to multiplying by 10. For example, "-F120" was used to select 12 point type above. Margins are measured in the default PostScript coordinate system: the origin is at the lower left corner of the page, x increases to the right, and y increases upwards. For example, the upper right corner of an 8 1/2" x 11" page would have an x-coordinate of 6120 and a y-coordinate of 7920. Following is a list of all the options: -Ccompression Compression factor for body font. This is a number from 1 to 500 representing the percentage by which the font's normal character width is compressed or expanded. Examples: -C50 produces a half-wide font, and -C200 produces a double-wide font. The default pitch of 10 pt. Courier is 12 cpi. -C72 causes it to print at 16.66 cpi. -ccompression Compression factor for header font. -Ilpi Lines per inch x 100. Line spacing defaults to the point size; for example, lines in a 12 pt. font are spaced 12/72 = 1/6" apart, giving 6 lpi. 4 lpi would be entered as -I400, 8 1/2 lpi as -I850. -L Landscape orientation. The default is portrait. -N Turn off header. The default is to print a header for every page. -n Prefix each line with a 5-digit line number. Default is no line numbers. -2 Set text in two columns. The default is one column. -X Do not separate columns with a rule line. In two-column mode, a vertical line normally separates the columns. -4 Print four half-size pages per sheet, i.e., 4-up. -Z Do not separate 4-up pages with rule lines. Normally, two lines are drawn in a cross to separate the miniature pages. -#copies Select number of copies. -Ffont Select body font. Postscript font, resident or downloaded, to be used for the main body of text. -ffont Header font. -Bfilename Beginning-of-page file. The user may create a PostScript file that is executed before each page is formatted. Because of PostScript's "opaque paint" imaging model, marks laid down by this file may overwritten by the page. A possible use might be to print "CONFIDENTIAL" or "DRAFT" in grey letters across each page. -Efilename End-of page file. The user may create a PostScript file that is executed before each page is formatted. Because of postScript's "opaque paint" imaging model, marks laid down by this file may overwrite the page text. Possible use might be to draw borders around each page, print a company logo, or print a custom page header. -Tncols Tab stop. Set tab stops at every ncols column. The default is 8. -Gsize Page size, where size is a code from 0 to 5, as follows: Code Paper SizeDimensions 0 letter 8 1/2" x 11" 1 legal 8 1/2" x 14" 2 ledger 11" x 17" 3 A3 297 mm x 420 mm 4 A4 210 mm x 297 mm 5 A5 182 mm x 257 mm The default margins are based on the page size. -Psize Body point size (decipoints). Size of font used for main body of test. -psize Header point size (decipoints). Size of font used for header. -tbydist Body top margin (decipoints). The main text begins printing at this distance from the bottom of the page. For example, to leave a top margin of 2" on legal size paper, set tb to (14 - 2) x 720 = 8640. Default is page length less 1" (720 decipoints). -lbxdist Body left margin. The main text begins printing at this distance from the left edge of the page. The default is 3/4" (540 decipoints). -bbydist Body bottom margin. The last line on each page is printed at this distance from the bottom of the page. The default is 1/2" (360 decipoints). -thydist Header top margin. The page header is printed at this distance from the bottom of the page. The default is page length less 1/2" (360 decipoints). -lhxdist Header left margin. The header time and date are printed at this distance from the left edge of the paper. The default is 1/2" (360 decipoints). -rhxdist Header right margin. The header page number is printed right-justified at this distance from the left edge of the paper. The default is the paper width less than 1/2" (360 decipoints). When the -2 option is selected in conjunction with landscape mode, the effect is similar to printing pages 2-up. There is still only one logical page, however, so only one header printed. Files invoked by the -B and -E options likewise are executed only once. The default font for this combination is 7 pt. Courier. When the -4 option is selected, all attributes of each page, including the header, margins, fonts, and any marks made by beginning-of-page and end-of-page files, are scaled to half size. Four exact, miniature replicas of a full size page are printed on each page. The -4, -2, and -L options may all be used together, resulting in an effective "8-up" appearance. The default type is a 3 1/2 pt. Courier, which is still large enough to be legible. The -B and -E options are intended for users with some knowledge of PostScript. Three PostScript strings can be accessed by the files used with these options: Name Contents DT Time and Plate PG Page Number FL File Name These strings can be used to design custom page headers, in conjunction with the -N option to turn off the default header. The format of the DT string is illustrated by the following example: Fri Sep 23 11:18:14 1992 All of the fields are constant width, so the PostScript getinterval can be used to break up the string and rearrange the fields, if desired. The coordinate system inherited by the beginning- and end-of-page files is not quite the default coordinate system: the origin is still in the lower left corner, but the units are scaled to decipoints (1/720") in both directions. If the -4 option is used, the whole page is scaled and repositioned. Users should treat this case the same as the one-page-per-sheet case remembering that the beginning- and end-of-page files are executed four times per sheet, once for each reduced page. It is important to bracket the custom PostScript with gsave and grestore, otherwise the main page inherits any changes made to the graphics state and unexpected output may result. Here is a sample beginning-of-page file that prints "CONFIDENTIAL" diagonally across a letter size page in gray letters about 1/2" high. gsave 52.3 rotate /Helvetica findfont 540 scalefont setfont 3047 -202 moveto (CONFIDENTIAL) show grestore PostScriptþ is a registered trademark of Adobe Systems; LaserJetþ is a registered trademark of Hewlett-Packard; Courierþ is a trademark of Smith-Corona; Helveticaþ is a registered trademark of Linotype AG; MS-DOSþ is a registered trademark of Microsoft; IBM PCþ and IBMþ are registered trademarks of IBM; Sunþ is a registered trademark of Sun Microsystems; Diabloþ is a registered trademark of Xerox; UNIXþ is a registered trademark of UNIX Systems Laboratories.