Version 12 of Postscript

Updated 2002-08-17 07:35:02

Postscript is a programming language (in reverse polish notation, see RPN in Tcl) that is used mostly for representing printable documents. More decent printers usually understand (interpret) Postscript right away.

Popular tools to visualize Postscript files are ghostscript/ghostview [L1 ].

The Postscript Language Reference Manual and some related specifications can be found at [L2 ].

Syntax in brief: Words are separated by whitespace, but the ten special characters %/(){}[]<> also end the previous word (with some exceptions). % starts a comment, that continues to the end of the line. / before a word makes that word literal (prevents that it is executed). Parentheses delimit strings; \ is escape character in strings. Braces delimit procedures (executable arrays); they work sort of like in Tcl. Brackets construct normal arrays, which are similar to lists in Tcl, except that they have fixed length :-(. The PS code

 a [b /c /d e] f

is sort of equivalent to Tcl

 $a [list $b c d $e] $f

or (if f is more of a command than a variable)

 f $a [list $b c d $e]

A typical Postscript file starts with a %! comment, and it usually contains a couple of %% comments that contain markup for programs that manipulate Postscript files.

 %!
 %%Creator: Gif2PS
 /#copies 1 def

The last line is an assignment: "assign to the variable #copies the value 1", or set #copies 1 as we would say in Tcl.

See also Manipulating Postscript.


Category Language