Capturing PostScript Output
Published By | Date | Version | Knowledge Level | Keywords |
---|---|---|---|---|
Revelation Technologies | 18 DEC 1991 | 2.1X | EXPERT | POSTSCRIPT, PRINTERS, PRINTING, OUTPUT, PRINTPROC, PSPRINT, GET_PS_FILE_NAME |
When using the new PostScript printer driver in Advanced Revelation Version 2.1, you may occasionally want to capture the PostScript output that would normally be sent to the printer. This bulletin describes the process required.
Temporary PostScript Output
A PostScript printer does not directly process incoming printer streams. Instead, it requires that an entire PostScript program be downloaded to it; the printer then executes the program to produce printer output. The printer is, in effect, a computer itself, whose "native language" (and input) is PostScript.
To accommodate PostScript printers, Advanced Revelation captures the output intended for the printer and holds it in a temporary file. When the job is complete, Advanced Revelation uses the temporary output and writes the PostScript program required to drive the PostScript printer for the desired output.
The temporary file is opened whenever a new print job is begun. This happens:
- When the PostScript driver is selected.
- At login.
- When a PRINTPROC OPEN command is executed from TCL.
- From a TCL first-level reset.
The temporary file is maintained until the print job is closed, ordinarily at the execution of the PRINTPROC or PRINTPROC CLOSE command.
The PSPRINT Command
Once the print job is closed and the temporary file finished, a process called PSPRINT reads the temporary file, creates the PostScript program, and writes the result to the printer. To capture the PostScript output, therefore, you must first redirect output to a file, and then explicitly call the PSPRINT command before the print job is allowed to close. The PSPRINT command has the syntax:
PSPRINT temp_filename
where temp_filename is the name of a DOS file that contains the spooled printer output. For more information about how this file is named, see "Temporary File Name" below.
Temporary File Name
The temporary output file initialized by the PRINTPROC OPEN command is created using a filename based on the current station id. It has a format of:
R + hashed_@station + .PSS
If you are running on a single-user system, the temporary file name will almost certainly be the only file on your sort path with a mask of R*.PSS.
However, if you are running on a network, the temporary file name includes your station ID to ensure that the file name is unique. If the station ID is longer than 5 characters, the system executes an algorithm that produces a unique filename. The code that creates the hashed name appears in Figure 1.
Once the file name has been created, the file is initialized on the current Sort File Path. The value of this environment setting is available in the system variable @ENVIRON.SET<E.DOS.SORT.VOL> (field 43).
Steps for Capturing Output
The steps required to capture the output are:
- Select the PostScript driver.
- Initialize a print job (and temporary file) using PRINTPROC OPEN.
- Create printer output as normal.
- Redirect printer output to the eventual target file using PDISK.
- Format the PostScript program and write it to the printer using PSPRINT. Because printer output was redirected in step (4), however, the output is sent to a file.
- Close the target file using PDISK PRN.
Example Sequence
The following shows a set of commands, all executed at TCL, that would result in a file C:\TEMP\POSTSCRP.TXT with the PostScript program for the print job:
PRINTPROC ON LIST 10 VOC (P PDISK C:\TEMP\POSTSCRP.TXT PSPRINT R5628747.PSS PDISK PRN
Note: The PSPRINT command in this example uses an explicit file name. This file name would be different in your system according to your own station ID.
Examples
Figure 1
FUNCTION GET_PS_FILE_NAME /* program: get_ps_file_name desc: function to return a unique DOS filename based on the current station id. Designed to return the name of a temporary output file used by the PostScript printer driver in Advanced Revelation 2.1. Includes the path returned from the Sort File Path setting in the environment. */ $INSERT INCLUDE,ENVIRON.CONSTANTS STATION =@STATION T$STATION=STATION SORT_PATH = @ENVIRON.SET< E.DOS.SORT.VOL > IF SORT_PATH THEN IF LEN(SORT_PATH) EQ 1 AND SORT_PATH NE '\' THEN SORT_PATH:=':' ; * single drive letter END IF SORT_PATH[-1,1] EQ '\' OR SORT_PATH[-1,1] EQ ':' ELSE SORT_PATH:='\' END END * filter out all characters except numbers, uc/lc letters CONVERT '0123456789':@UPPER.CASE:@LOWER.CASE TO '' IN T$STATION CONVERT T$STATION TO '' IN STATION STATION.LEN = LEN( STATION ) IF STATION.LEN GT 5 THEN T$STATION = 1 FOR CTR = 1 TO STATION.LEN T$STATION = MOD((T$STATION + SEQ(STATION[CTR,1])) * 3, 10000000) NEXT CTR STATION = T$STATION END PS_FILE_NAME = 'R':STATION:'.PSS' RETURN SORT_PATH : PS_FILE_NAME