Adobe PostScript Language Reference

Operator Types

Operand Stack Manipulation Miscellaneous Operators
Arithmetic and Math Operators Graphics State Operators
Array Operators Coordinate System and Matrix
Dictionary Operators Path Construction Operators
String Operators Painting Operators
Relational, Boolean, and Bitwise Device Setup and Output
Control Operators Character and Font Operators
Type, Attribute, and Conversion Font Cache Operators
File Operators Errors
Virtual Memory Operators PostScript Level 2

 

Operand Stack Manipulation Operators

Operator Syntax Description
any pop Discard top element.
any1 any2 exch Exchange top two elements.
any dup Duplicate top element.
any1..anyn n copy Duplicate top n elements.
anyn any0 n index Duplicate arbitrary element.
an-1..a0 n j roll Roll n elements up j times.
any1..anyn clear Discard all elements.
any1..anyn count Count elements on stack.
mark Push mark on stack.
mark obj1..objn cleartomark Discard elements down through mark.
mark obj1..objn counttomark Count elements down to mark.

 

Arithmetic and Math Operators

Operator Syntax Description
num1 num2 add num1 plus num2.
num1 num2 div num1 divided by num2.
int1 int2 idiv Integer divide.
int1 int2 mod int1 mod int2.
num1 num2 mul num1 times num2.
num1 num2 sub num1 minus num2.
num1 abs Absolute value of a num1.
num1 neg Negative of num1.
num1 ceiling Ceiling of num1.
num1 floor Floor of num1.
num1 round Round num1 to nearest integer.
num1 truncate Remove fractional part of num1.
num sqrt Square root of num.
num den atan Arctangent of num/den in degrees.
angle cos Cosine of angle (degrees).
angle sin Sine of angle (degrees).
base exponent exp Raise base to exponent power.
num ln Natural logarithm (base e).
num log Logarithm (base 10).
rand Generate pseudo-random integer.
int srand Set random number seed.
rrand Return random number seed.

 

Array Operators

Operator Syntax Description
int array Create array of length int.
[ Start array construction.
mark obj0..objn-1 ] End array construction.
array length Number of elements in array.
array index get Get array element indexed by index.
array index any put Put any into array at index.
array index count getinterval Subarray of array starting at index for count.
array1 index array2 putinterval Replace subarray of array1 starting at index by array2.
array aload Push all elements of array on stack.
any0..anyn-1 array astore Pop elements from stack into array.
array1 array2 copy Copy elements of array1 to initial subarray of array2.
array proc forall Execute proc for each element of array.

 

Dictionary Operators

Operator Syntax Description
int dict Create dictionary with capacity for int.
dict length Number of key-value pairs in dict.
dict maxlenth Capacity of dict.
dict begin Push dict on dict stack.
end Pop dict stack.
key value def Associate key and value in current dict.
key load Search dict stack for key and return associated value.
key value store Replace topmost definition of key.
dict key get Get value associated with key in dict.
dict key value put Associate key with value in dict.
dict key known Test whether key is in dict.
key where Find dict in which key is defined.
dict1 dict2 copy Copy contents of dict1 to dict2.
dict proc forall Execute proc for each element of dict.
errordict Push errordict on operand stack.
systemdict Push systemdict on operand stack.
userdict Push userdict on operand stack.
currentdict Push current dict on operand stack.
countdictstack Count elements on dict stack.
array dictstack Copy dict stack into array.

 

String Operators

Operator Syntax Description
int string Create string of length int.
string length Number of elements in string.
string index get Get string element indexed by index.
string index int put Put int into string at index.
string index count getinterval Substring of string starting at index for count elements.
string1 index string2 putinterval Replace substring of string1 starting at index by string2.
string1 string2 copy Copy elements of string1 to initial substring of string2.
string proc forall Execute proc for each element of string.
string seek anchorsearch Determine if seek is initial substring of string.
string seek search Search for seek in string.
string token Read token from start of string.

 

Relational, Boolean, and Bitwise Operators

Operator Syntax Description
any1 any2 eq Test equal.
any1 any2 ne Test not equal.
num1|str1 num2|str2 ge Test greater or equal.
num1|str1 num2|str2 gt Test greater than.
num1|str1 num2|str2 le Test less or equal.
num1|str1 num2|str2 lt Test less than.
bool1|int1 bool2|int2 and Logical | bitwise and.
bool1|int1 not Logical | bitwise not.
bool1|int1 bool2|int2 or Logical | bitwise inclusive or.
bool1|int1 bool2|int2 xor Logical | bitwise exclusive or.
true Push boolean value true.
false Push boolean value false.
int1 shift bitshift Bitwise shift of int1.

 

Control Operators

Operator Syntax Description
any exec Execute arbitrary object.
bool proc if Execute proc if bool is true.
bool proc1 proc2 ifelse Execute proc1 if bool is true, proc2 if bool is false.
init incr limit proc for Execute proc with values from init by steps of incr to limit.
int proc repeat Execute proc int times
proc loop Execute proc an indefinite number of times.
exit Exit innermost active loop.
stop Terminate stopped context.
any stopped Establish context for catching stop.
countexecstack Count elements on exec stack.
array execstack Copy exec stack into array.
quit Terminate interpreter.
start Executed at interpreter startup.

 

Type, Attribute, and Conversion Operators

Operator Syntax Description
any type Return name identifying any's type.
any cvlit Make object be literal.
any cvx Make object be executable.
any xcheck Test executable attribute.
array|file|string executeonly Reduce access to execute-only.
array|dict|file|string noaccess Disallow any access.
array|dict|file|string readonly Reduce access to read-only.
array|dict|file|string rcheck Test read access.
array|dict|file|string wcheck Test write access.
num|string cvi Convert to integer.
string cvn Convert to name.
num|string cvr Convert to real.
num radix string cvrs Convert to string with radix.
any string cvs Convert to string.

 

File Operators

Operator Syntax Description
string1 string2 file Open file identified by string1 with access string2.
file closefile Close File.
file read Read one Character from file.
file int write Write one Character to file.
file string readhexstring Read hex from file into string.
file string writehexstring Write string to file as hex.
file string readstring Read string from file.
file string writestring Write characters of string to file.
file string readline Read line from file into string.
file token Read token from file.
file bytesavailable Number of bytes available to read.
flush Send buffered data to standard output file.
file flushfile Send buffered data or read to EOF.
file resetfile Discard buffered characters.
file status Return status of file.
string run Execute contents of named file.
currentfile Return file currently being executed.
string print Write characters of string to standard output file.
any = Write text representation of any to standard output file.
any1...anyn stack Print stack nondestructively using =.
any == Write syntactic representation of any to standard output file.
any1...anyn pstack Print stack nondestructively using ==.
prompt Executed when ready for interactive input.
bool echo Turn on/off echoing.

 

Virtual Memory Operators

Operator Syntax Description
save Create VM snapshot.
save restore Restore VM snapshot.
vmstatus Level used maximum.

 

Miscellaneous Operators

Operator Syntax Description
proc Bindbind Replace operator names in proc by operators.
null Push null on operand stack.
usertime Return time in milliseconds.
version Interpreter version.

 

Graphics State Operators

Operator Syntax Description
gsave Save graphics state.
grestore Restore graphics state.
grestoreall Restore to bottommost graphics state.
initgraphics Reset graphics state parameters.
num setlinewidth Set line width.
currentlinewidth Return current line width.
int setlinecap Set shape of line ends for stroke.
currentlinecap Return current line cap.
int setlinejoin Set shape of corners for stroke.
currentlinejoin Return current line join.
num setmiterlimit Set miter length limit.
currentmiterlimit Return current miter limit.
array offset setdash Set dash pattern for stroking.
currentdash Return current dash pattern.
num setflat Set flatness tolerance.
currentflat Return current flatness.
num setgray Set color to gray value from 0 (black) to 1 (white).
currentgray Return current gray.
hue sat brt sethsbcolor Set color given hue, saturation, brightness.
currenthsbcolor Return current color hue, saturation, brightness.
red green blue setrgbcolor Set color given red, green, blue.
currentrgbcolor Return current color red, green, blue.
freq angle proc setscreen Set halftone screen.
currentscreen Return current halftone screen.
proc settransfer Set gray transfer function.
currenttransfer Return current transfer function.

 

Coordinate System and Matrix Operators

Operator Syntax Description
matrix Create identity matrix.
initmatrix Set CTM to device default.
matrix identmatrix Fill matrix with identity transform.
matrix defaultmatrix Fill matrix with device default matrix.
matrix currentmatrix Fill matrix with CTM.
matrix setmatrix Replace CTM by matrix.
tx ty translate Translate user space by (tx, ty).
tx ty matrix translate Define translation by (tx, ty).
sx sy scale Scale user space by sx and sy.
sx sy matrix scale Define Scalingscaling by sx and sy.
angle rotate Rotate user space by angle degrees.
angle matrix rotate Define rotation by angle degrees.
matrix concat Replace CTM by matrix X CTM.
matrix1 matrix2 matrix3 concatmatrix Fill matrix3 with matrix1 X matrix2.
x y transform Transform (x, y) by CTM.
x y matrix transform Transform (x, y) by matrix.
dx dy dtransform Transform distance (dx, dy) by CTM.
dx dy matrix dtransform Transform distance (dx, dy) by matrix.
x' y' itransform Inverse transform (x', y') by CTM.
x' y' matrix itransform Inverse transform (x', y') by matrix.
dx' dy' idtransform Inverse transform distance (dx', dy') by CTM.
dx' dy' matrix idtransform Inverse transform distance (dx', dy') by matrix.
matrix1 matrix2 invertmatrix Fill matrix2 with inverse of matrix1.

 

Path Construction Operators

Operator Syntax Description
newpath Initialize current path to be empty.
currentpoint Return current point coordinate.
x y moveto Set current point to (x, y).
dx dy rmoveto Relative moveto.
x y lineto Append straightline to (x, y).
dx dy rlineto Relative lineto.
x y r ang1 ang2 arc Append counterclockwise arc.
x y r ang1 ang2 arcn Append clockwise arc.
x1 y1 x2 y2 r arcto Append tangent arc.
x1 y1 x2 y2 x3 y3 curveto Append Bezier cubic section
dx1 dy1 dx2 dy2 dx3 dy3 rcurveto Relative curveto.
closepath Connect subpath back to its starting point.
flattenpath Convert curves to sequences of straight lines.
reversepath Reverse direction of current path.
strokepath Compute outline of stroked path.
string bool charpath Append Character outline to current path.
clippath Set current path to Clippingclipping path.
pathbox Return Bounding Boxbounding of current path.
move line curve close pathforall Enumerate current path.
initclip Set clip path to device default.
clip Establish new Clippingclipping path.
eoclip Clip using even-odd inside rule.

 

Painting Operators

Operator Syntax Description
erasepage Paint current page white.
fill Fill current path with current color.
eofill Fill using even-odd rule.
stroke Draw line along current path.
width height bits/sample matrix proc image Render sampled image onto current page.
width height invert matrix proc imagemask Render mask onto current page.

 

Device Setup and Output Operators

Operator Syntax Description
showpage Output and reset current page.
copypage Output current page.
matrix width height proc banddevice Install Bandband Bufferbuffer device.
matrix width height proc framedevice Install frame Bufferbuffer device.
nulldevice Install no-output device.
proc renderbands Enumerate bands for output to device.

 

Character and Font Operators

Operator Syntax Description
key Font definefont Register Font as a font dictionary.
key findfont Return Font dict identified by key.
Font scale scalefont Scale Font by scale to produce new font'.
Font matrix makefont Transform Font by matrix to produce new font'.
Font setfont Set Font dictionary.
currentfont Return current Font dictionary.
string show Print characters of string on page.
ax ay string ashow Add (ax, ay) to width of each char while showing string.
cx cy char string widthshow Add (cx, cy) to width of char while showing string.
cx cy char ax ay string awidthshow Combined effect of ashow and widthshow.
proc string kshow Execute proc between characters show from string.
string stringwidth Width of string in current Font.
FontDirectory Dictionary of Font dictionaries.
StandardEncoding Standard Font encoding vector.

 

Font Cache Operators

Operator Syntax Description
cachestatus Return cache status and paramaters.
wx wy llx lly urx ury setcachedevice Declare cached Character metrics.
wx wy setcharwidth Declare uncached Character metrics.
num setcachelimit Set max bytes in cached Character.

 

Errors

Error Description
dictfull No more room in dictionary.
dictstackoverflow To many begins.
dictstackunderflow Too many ends.
execstackoverflow Exec nesting too deep.
handleerror Called to report error information.
interrupt External interrupt request.
invalidaccess Attempt to violate access attribute.
invalidexit Exit not in loop.
invalidfileaccess Unacceptable access string.
invalidfont Invalid Font name or dict.
invalidrestore Improper restore.
ioerror Input/output error occurred.
limitcheck Implementation limit exceeded.
nocurrentpoint Current point is undefined.
rangecheck Operand out of bounds.
stackoverflow Operand stack overflow.
stackunderflow Oper stack underflow.
syntaxerror Syntax error in PostScriptpostscript program text.
Timeouttimeout Time limit exceeded.
typecheck Operand of wrong type.
undefined Name not known.
undefinedfilename File not found.
undefinedresult Over/underflow or meaningless result.
unmatchedmark Expected mark not on stack.
unregistered Internal error.
VMerror VM exhausted.