Operand Stack Manipulation Operators

Operator SyntaxDescription
any popDiscard top element.
any1 any2 exchExchange top two elements.
any dupDuplicate top element.
any1..anyn n copyDuplicate top n elements.
anyn any0 n indexDuplicate arbitrary element.
an-1..a0 n j rollRoll n elements up j times.
any1..anyn clearDiscard all elements.
any1..anyn countCount elements on stack.
markPush mark on stack.
mark obj1..objn cleartomarkDiscard elements down through mark.
mark obj1..objn counttomarkCount elements down to mark.

 

Arithmetic and Math Operators

Operator SyntaxDescription
num1 num2 addnum1 plus num2.
num1 num2 divnum1 divided by num2.
int1 int2 idivInteger divide.
int1 int2 modint1 mod int2.
num1 num2 mulnum1 times num2.
num1 num2 subnum1 minus num2.
num1 absAbsolute value of a num1.
num1 negNegative of num1.
num1 ceilingCeiling of num1.
num1 floorFloor of num1.
num1 roundRound num1 to nearest integer.
num1 truncateRemove fractional part of num1.
num sqrtSquare root of num.
num den atanArctangent of num/den in degrees.
angle cosCosine of angle (degrees).
angle sinSine of angle (degrees).
base exponent expRaise base to exponent power.
num lnNatural logarithm (base e).
num logLogarithm (base 10).
randGenerate pseudo-random integer.
int srandSet random number seed.
rrandReturn random number seed.

 

Array Operators

Operator SyntaxDescription
int arrayCreate array of length int.
[Start array construction.
mark obj0..objn-1 ]End array construction.
array lengthNumber of elements in array.
array index getGet array element indexed by index.
array index any putPut any into array at index.
array index count getintervalSubarray of array starting at index for count.
array1 index array2 putintervalReplace subarray of array1 starting at index by array2.
array aloadPush all elements of array on stack.
any0..anyn-1 array astorePop elements from stack into array.
array1 array2 copyCopy elements of array1 to initial subarray of array2.
array proc forallExecute proc for each element of array.

 

Dictionary Operators

Operator SyntaxDescription
int dictCreate dictionary with capacity for int.
dict lengthNumber of key-value pairs in dict.
dict maxlenthCapacity of dict.
dict beginPush dict on dict stack.
endPop dict stack.
key value defAssociate key and value in current dict.
key loadSearch dict stack for key and return associated value.
key value storeReplace topmost definition of key.
dict key getGet value associated with key in dict.
dict key value putAssociate key with value in dict.
dict key knownTest whether key is in dict.
key whereFind dict in which key is defined.
dict1 dict2 copyCopy contents of dict1 to dict2.
dict proc forallExecute proc for each element of dict.
errordictPush errordict on operand stack.
systemdictPush systemdict on operand stack.
userdictPush userdict on operand stack.
currentdictPush current dict on operand stack.
countdictstackCount elements on dict stack.
array dictstackCopy dict stack into array.

 

String Operators

Operator SyntaxDescription
int stringCreate string of length int.
string lengthNumber of elements in string.
string index getGet string element indexed by index.
string index int putPut int into string at index.
string index count getintervalSubstring of string starting at index for count elements.
string1 index string2 putinterval Replace substring of string1 starting at index by string2.
string1 string2 copyCopy elements of string1 to initial substring of string2.
string proc forallExecute proc for each element of string.
string seek anchorsearchDetermine if seek is initial substring of string.
string seek searchSearch for seek in string.
string tokenRead token from start of string.

 

Relational, Boolean, and Bitwise Operators

Operator SyntaxDescription
any1 any2 eqTest equal.
any1 any2 neTest not equal.
num1|str1 num2|str2 geTest greater or equal.
num1|str1 num2|str2 gtTest greater than.
num1|str1 num2|str2 leTest less or equal.
num1|str1 num2|str2 ltTest less than.
bool1|int1 bool2|int2 andLogical | bitwise and.
bool1|int1 notLogical | bitwise not.
bool1|int1 bool2|int2 orLogical | bitwise inclusive or.
bool1|int1 bool2|int2 xorLogical | bitwise exclusive or.
truePush boolean value true.
falsePush boolean value false.
int1 shift bitshiftBitwise shift of int1.

 

Control Operators

Operator SyntaxDescription
any execExecute arbitrary object.
bool proc ifExecute proc if bool is true.
bool proc1 proc2 ifelseExecute proc1 if bool is true, proc2 if bool is false.
init incr limit proc forExecute proc with values from init by steps of incr to limit.
int proc repeatExecute proc int times
proc loopExecute proc an indefinite number of times.
exitExit innermost active loop.
stopTerminate stopped context.
any stoppedEstablish context for catching stop.
countexecstackCount elements on exec stack.
array execstackCopy exec stack into array.
quitTerminate interpreter.
startExecuted at interpreter startup.

 

Type, Attribute, and Conversion Operators

Operator SyntaxDescription
any typeReturn name identifying any's type.
any cvlitMake object be literal.
any cvxMake object be executable.
any xcheckTest executable attribute.
array|file|string executeonlyReduce access to execute-only.
array|dict|file|string noaccessDisallow any access.
array|dict|file|string readonlyReduce access to read-only.
array|dict|file|string rcheckTest read access.
array|dict|file|string wcheckTest write access.
num|string cviConvert to integer.
string cvnConvert to name.
num|string cvrConvert to real.
num radix string cvrsConvert to string with radix.
any string cvsConvert to string.

 

File Operators

Operator SyntaxDescription
string1 string2 fileOpen file identified by string1 with access string2.
file closefileClose File.
file readRead one Character from file.
file int writeWrite one Character to file.
file string readhexstringRead hex from file into string.
file string writehexstringWrite string to file as hex.
file string readstringRead string from file.
file string writestringWrite characters of string to file.
file string readlineRead line from file into string.
file tokenRead token from file.
file bytesavailableNumber of bytes available to read.
flushSend buffered data to standard output file.
file flushfileSend buffered data or read to EOF.
file resetfileDiscard buffered characters.
file statusReturn status of file.
string runExecute contents of named file.
currentfileReturn file currently being executed.
string printWrite characters of string to standard output file.
any =Write text representation of any to standard output file.
any1...anyn stackPrint stack nondestructively using =.
any ==Write syntactic representation of any to standard output file.
any1...anyn pstackPrint stack nondestructively using ==.
promptExecuted when ready for interactive input.
bool echoTurn on/off echoing.

 

Virtual Memory Operators

Operator SyntaxDescription
saveCreate VM snapshot.
save restoreRestore VM snapshot.
vmstatusLevel used maximum.

 

Miscellaneous Operators

Operator SyntaxDescription
proc BindbindReplace operator names in proc by operators.
nullPush null on operand stack.
usertimeReturn time in milliseconds.
versionInterpreter version.

 

Graphics State Operators

Operator SyntaxDescription
gsaveSave graphics state.
grestoreRestore graphics state.
grestoreallRestore to bottommost graphics state.
initgraphicsReset graphics state parameters.
num setlinewidthSet line width.
currentlinewidthReturn current line width.
int setlinecapSet shape of line ends for stroke.
currentlinecapReturn current line cap.
int setlinejoinSet shape of corners for stroke.
currentlinejoinReturn current line join.
num setmiterlimitSet miter length limit.
currentmiterlimitReturn current miter limit.
array offset setdashSet dash pattern for stroking.
currentdashReturn current dash pattern.
num setflatSet flatness tolerance.
currentflatReturn current flatness.
num setgraySet color to gray value from 0 (black) to 1 (white).
currentgrayReturn current gray.
hue sat brt sethsbcolorSet color given hue, saturation, brightness.
currenthsbcolorReturn current color hue, saturation, brightness.
red green blue setrgbcolorSet color given red, green, blue.
currentrgbcolorReturn current color red, green, blue.
freq angle proc setscreenSet halftone screen.
currentscreenReturn current halftone screen.
proc settransferSet gray transfer function.
currenttransferReturn current transfer function.

 

Coordinate System and Matrix Operators

Operator SyntaxDescription
matrixCreate identity matrix.
initmatrixSet CTM to device default.
matrix identmatrixFill matrix with identity transform.
matrix defaultmatrixFill matrix with device default matrix.
matrix currentmatrixFill matrix with CTM.
matrix setmatrixReplace CTM by matrix.
tx ty translateTranslate user space by (tx, ty).
tx ty matrix translateDefine translation by (tx, ty).
sx sy scaleScale user space by sx and sy.
sx sy matrix scaleDefine Scalingscaling by sx and sy.
angle rotateRotate user space by angle degrees.
angle matrix rotateDefine rotation by angle degrees.
matrix concatReplace CTM by matrix X CTM.
matrix1 matrix2 matrix3 concatmatrix Fill matrix3 with matrix1 X matrix2.
x y transformTransform (x, y) by CTM.
x y matrix transformTransform (x, y) by matrix.
dx dy dtransformTransform distance (dx, dy) by CTM.
dx dy matrix dtransformTransform distance (dx, dy) by matrix.
x' y' itransformInverse transform (x', y') by CTM.
x' y' matrix itransformInverse transform (x', y') by matrix.
dx' dy' idtransformInverse transform distance (dx', dy') by CTM.
dx' dy' matrix idtransformInverse transform distance (dx', dy') by matrix.
matrix1 matrix2 invertmatrixFill matrix2 with inverse of matrix1.

 

Path Construction Operators

Operator SyntaxDescription
newpathInitialize current path to be empty.
currentpointReturn current point coordinate.
x y movetoSet current point to (x, y).
dx dy rmovetoRelative moveto.
x y linetoAppend straightline to (x, y).
dx dy rlinetoRelative lineto.
x y r ang1 ang2 arcAppend counterclockwise arc.
x y r ang1 ang2 arcnAppend clockwise arc.
x1 y1 x2 y2 r arctoAppend tangent arc.
x1 y1 x2 y2 x3 y3 curvetoAppend Bezier cubic section
dx1 dy1 dx2 dy2 dx3 dy3 rcurvetoRelative curveto.
closepathConnect subpath back to its starting point.
flattenpathConvert curves to sequences of straight lines.
reversepathReverse direction of current path.
strokepathCompute outline of stroked path.
string bool charpathAppend Character outline to current path.
clippathSet current path to Clippingclipping path.
pathboxReturn Bounding Boxbounding of current path.
move line curve close pathforallEnumerate current path.
initclipSet clip path to device default.
clipEstablish new Clippingclipping path.
eoclipClip using even-odd inside rule.

 

Painting Operators

Operator SyntaxDescription
erasepagePaint current page white.
fillFill current path with current color.
eofillFill using even-odd rule.
strokeDraw 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 SyntaxDescription
showpageOutput and reset current page.
copypageOutput current page.
matrix width height proc banddevice Install Bandband Bufferbuffer device.
matrix width height proc framedevice Install frame Bufferbuffer device.
nulldeviceInstall no-output device.
proc renderbandsEnumerate bands for output to device.

 

Character and Font Operators

Operator SyntaxDescription
key Font definefontRegister Font as a font dictionary.
key findfontReturn Font dict identified by key.
Font scale scalefontScale Font by scale to produce new font'.
Font matrix makefontTransform Font by matrix to produce new font'.
Font setfontSet Font dictionary.
currentfontReturn current Font dictionary.
string showPrint characters of string on page.
ax ay string ashowAdd (ax, ay) to width of each char while showing string.
cx cy char string widthshowAdd (cx, cy) to width of char while showing string.
cx cy char ax ay string awidthshow Combined effect of ashow and widthshow.
proc string kshowExecute proc between characters show from string.
string stringwidthWidth of string in current Font.
FontDirectoryDictionary of Font dictionaries.
StandardEncodingStandard Font encoding vector.

 

Font Cache Operators

Operator SyntaxDescription
cachestatusReturn cache status and paramaters.
wx wy llx lly urx ury setcachedevice Declare cached Character metrics.
wx wy setcharwidthDeclare uncached Character metrics.
num setcachelimitSet max bytes in cached Character.

 

Errors

ErrorDescription
dictfullNo more room in dictionary.
dictstackoverflowTo many begins.
dictstackunderflowToo many ends.
execstackoverflowExec nesting too deep.
handleerrorCalled to report error information.
interruptExternal interrupt request.
invalidaccessAttempt to violate access attribute.
invalidexitExit not in loop.
invalidfileaccessUnacceptable access string.
invalidfontInvalid Font name or dict.
invalidrestoreImproper restore.
ioerrorInput/output error occurred.
limitcheckImplementation limit exceeded.
nocurrentpointCurrent point is undefined.
rangecheckOperand out of bounds.
stackoverflowOperand stack overflow.
stackunderflowOper stack underflow.
syntaxerrorSyntax error in PostScriptpostscript program text.
TimeouttimeoutTime limit exceeded.
typecheckOperand of wrong type.
undefinedName not known.
undefinedfilenameFile not found.
undefinedresultOver/underflow or meaningless result.
unmatchedmarkExpected mark not on stack.
unregisteredInternal error.
VMerrorVM exhausted.