HELIOS EtherShare 2.6 User manual


12 Text-to-PostScript
Converter
12.1 General remarks
This chapter describes the conversion of "flat" ASCII text files to PostScript print jobs with the help of the "pstext" program.
pstext
The "pstext" program in the "$ESDIR" directory allows simple ASCII files and files in "nroff" format to be printed on PostScript printers. Since PostScript printers usually cannot accept print jobs consisting of "flat" ASCII data, it is normally not possible to print UNIX program listings or to print from UNIX programs that only support a simple matrix printer. The necessary conversion can be made with this program. "pstext" can also check the print job for special sequences starting with the "ESC" character, which can be used to control simple highlighting features such as bold printing, underscoring, and different fonts.
The EtherShare Print Server is able to differentiate "flat" ASCII data from PostScript data automatically, and calls "pstext" to convert the job accordingly. Thus, it is usually not necessary to call "pstext" manually. See the nomagic parameter in chapter 11.6 "Configuring printers manually" for related information.
"pstext" is started from the command line in order to convert an existing file for printing, or from inside a UNIX pipe in order to be able to directly print from an application without having to spool the ASCII print output to disk. "pstext" can be controlled with additional parameters in typical UNIX style.
The following is an example of a typical command to print an ASCII file:
pstext -P lw .profile
This command converts the file ".profile" to PostScript and sends it to the printer "lw". To do this, "pstext" calls "lpr" with the specified printer name. "pstext" first looks for "lpr" in the $ESDIR directory (usually "/usr/local/es"), and then in the directories specified in the hosts's path. If the option "-P printername" is omitted, the generated PostScript code is output to the terminal for test purposes, rather than to the printer.
The following is an example of the use of "pstext" in a UNIX pipe. It outputs the current directory to the printer "lw":
ls -l | pstext -P lw
The following example prints one entry from the UNIX manual:
nroff -man /usr/man/man1/ls.1 | pstext -P lw
12.2 Options
The command line options of "pstext" have the following significance:
-f
font
font is the font with which the document should be printed. The default here is "Courier", because this is one of the few commonly available non-proportional fonts, which makes it particularly suitable for listings and tables.
-s
size
size is the size of the font in points. The default is 10 points. One point is 1/72 inch.
-e
prepfile
prepfile is the name of a PostScript language "prep" file which should be added to the start of each print job. If you do not specify the -e option, "pstext" automatically uses the internal "prep" file. This file contains definitions which are needed by "pstext". Instead of specifying an alternative "prep" file name in the command line with the -e option as above, you can set the name with the UNIX environment variable "$PSTEXT_PREP". This avoids having to specify the -e option. See the -d option below, and chapter 12.4 "Umlauts and special characters" for more information about using and editing the "prep" file.
-h
title
title is automatically printed on the top line of each page. If this option is omitted, "pstext" automatically prints the file name and the date on the top line.
-L
leftmargin
leftmargin specifies the space to the left paper edge in points. The default varies slightly from printer to printer, and is approximately 20 points.
-T
topmargin
topmargin is the spacing in points from the top paper edge. The default varies slightly from printer to printer and is approximately 14 points.
-o
This option suppresses the title line. You normally want to suppress the title line if you are using the "pstext" escape interpreter, because you are probably printing with a more "intelligent" program which generates its own header in this case.
-l
This option rotates the printed output by 90 (landscape mode printing).
-m
This option is used to print the date of the last modification to the file on the top line of each page, instead of the current date.
-n
This option turns off the "pstext" escape interpreter. No characters are checked for control functions.
-t
tabsize
tabsize specifies the distance of each tabulator stop in units of the width of the character "M". The default is eight, i.e. the width of eight Ms ("MMMMMMMM") for each tab stop.
-P
printer
printer is the name of the printer to which the file should be output. If this option is omitted, the generated PostScript code is output to the terminal ("stdout").
-c
lpi
lpi defines the desired line spacing in font height. The default is once the height of the used font.
-d
NewPrepFile
NewPrepFile parameter can be set to dump the internal "prep" file pstext.ps to a file for further editing and use it with -e option.

12.3 Escape Interpreter
"pstext" can check the print job for special sequences starting with the "ESC" character, which can be used to control simple highlighting features such as bold printing, underscoring and different fonts. This is particularly useful for programs that normally work with a matrix printer. With such programs, it is often possible to enter the control codes to specify particular print attributes such as bold printing into a configuration table.
An escape sequence for "pstext" has three parts: The first is the ESC character (Hex 1B), which is then followed by a command (a digit between one and six), followed by the value of the parameter within square brackets, for example:
ESC 4 [10]
or in hex:
1B 34 5B 31 30 5D
Escape
sequences
The following is a list of the supported escape sequences:
ESC 1 [1]
Underline on.
ESC 1 [0]
Underline off.
ESC 2 [1]
Bold printing on.
ESC 2 [0]
Bold printing off.
ESC 3 [Helvetica]
Choose a new font, in this example "Helvetica".
ESC 3 [Courier]
Choose the standard font. "Courier" is the
default font.
ESC 4 [12.5]
Choose a new font size in points, in this example
12.5 points.
ESC 5 [
gsave
newpath
50 50 moveto
80 80 lineto
closepath
stroke
grestore
]
This escape sequence example shows how to include your own PostScript code (e.g. a trademark) during the printing procedure. It is important to store and restore the current position, which is why the program should always start with "gsave" and finish with "grestore".
ESC 6 [2]
Set line spacing (in this example to 2 times the font
height).
12.4 Umlauts and special characters
"pstext" provides facilities to allow the PostScript coding (character set translation) of the printer font to be changed, for example to allow national accented characters such as Umlauts to be printed correctly. The default character set coding in PostScript only supports a few of the available accented characters. "pstext", however, re-codes the allocation of such characters by accessing the PostScript language "prep" file that is built into EtherShare. This file contains two different, modified versions of the so-called "Standard Encoding Vector", called "decEncoding" (for DEC Ultrix computers) and "ibmEncoding" (for IBM computers) respectively. Neither of these encoding tables are complete implementations of the corresponding character sets, they have only been set up to support the German Umlaut characters. However, they can easily be extended to add other special characters, or to specify completely new codings. Note that modification of the coding requires some knowledge of the PostScript language.
To edit the default "prep" file, you have to use the "pstext" program with the "-d" option. This dumps the "prep" contents into a file which can then be revised. We assume that the file name of the editable "prep" file is "pstext.ps".
The two alternative encoding tables can be found at the beginning of the "pstext.ps" file. They both function by copying the standard coding and changing it to add the required special characters. The following is the code table provided for the DEC VT200 character set:
% reencode font for DEC VT200 font
/decEncoding StandardEncoding dup length array copy
dup 196 /Adieresis put
dup 228 /adieresis put
dup 220 /Udieresis put
dup 252 /udieresis put
dup 214 /Odieresis put
dup 246 /odieresis put
dup 223 /germandbls put
def
Each line of this table re-defines a single character. The decimal number (e.g. 196) is the decimal value of the character ("ASCII" value) in the input file's character set. This is followed by the PostScript name of the character. In PostScript, characters have names and not numbers. For example, "/Adieresis" is the PostScript name for "".
The encoding tables are followed by a line which determines which of the two tables are used when printing. The table "decEncoding" implements a character set according to ISO 8859-1 (DEC VT200) whereas "ibmEncoding" implements a character set that corresponds to the IBM PC extended ASCII code. The following line in "pstext.ps" selects DEC encoding:
% we use the DEC encoding by default
/theEncoding decEncoding def

If you want to use IBM PC umlaut codes, change the above line as follows:
% we use the IBM encoding by default
/theEncoding ibmEncoding def

You can as well make a local copy of "pstext.ps" with a new - more individual - name, then modify this file, and specify its name with the -e option when calling "pstext", e.g.:
pstext -e myprep1.ps -P lw testfile
This command prints the file "testfile" using a new PostScript definition contained in the "prep" file "myprep1.ps". If you use a particular encoding table often, instead of specifying the "prep" file name in the command line as above, you can write the name to the UNIX environment variable "$PSTEXT_PREP". This avoids having to specify the "-e" option.


© 2002 HELIOS Software GmbH