PostScript’s built-in operators live in systemdict. They take their
operands from the stack and push their results; the groups below follow chapter 8 of
the PostScript Language Reference (third edition), and the level marks follow its
appendix A: unmarked operators are LanguageLevel 1, those marked ² came with
LanguageLevel 2 (some first as LanguageLevel 1 extensions for CMYK colour, composite
fonts and file systems) and ³ with LanguageLevel 3. Operators of Display PostScript and
printer-specific statusdict operators are not listed. LanguageLevel 2 also
had currentshared, setshared, scheck,
shareddict and SharedFontDirectory, older names for the
global VM operators, which the third edition no longer lists among the operators.
Stack, arithmetic and logic
| Group | Operators |
|---|---|
| Operand stack | pop exch dup copy index roll clear count mark cleartomark counttomark |
| Arithmetic and maths | add sub mul div idiv mod abs neg ceiling floor round truncate sqrt atan cos sin exp ln log rand srand rrand |
| Relational, boolean, bitwise | eq ne ge gt le lt and or xor not true false bitshift |
Arrays, dictionaries and strings
| Group | Operators |
|---|---|
| Array | array [ ] length get put getinterval putinterval astore aload copy forall |
| Packed array | packedarray² setpacking² currentpacking², and length get getinterval aload copy forall |
| Dictionary | dict <<² >>² length maxlength begin end def load store get put undef² known where copy forall currentdict errordict $error systemdict userdict globaldict² statusdict countdictstack dictstack cleardictstack |
| String | string length get put getinterval putinterval copy forall anchorsearch search token |
Control, conversion and files
| Group | Operators |
|---|---|
| Control | exec if ifelse for repeat loop exit stop stopped countexecstack execstack quit start |
| Type, attribute, conversion | type cvlit cvx xcheck executeonly noaccess readonly rcheck wcheck cvi cvn cvr cvrs cvs |
| File | file filter² closefile read write readhexstring writehexstring readstring writestring readline token bytesavailable flush flushfile resetfile status run currentfile deletefile² renamefile² filenameforall² setfileposition² fileposition² print = == stack pstack printobject² writeobject² setobjectformat² currentobjectformat² |
| Resource | defineresource² undefineresource² findresource² findcolorrendering³ resourcestatus² resourceforall² |
| Virtual memory | save restore setglobal² currentglobal² gcheck² startjob² defineuserobject² execuserobject² undefineuserobject² UserObjects² |
| Miscellaneous | bind null version realtime² usertime languagelevel² product² revision² serialnumber² executive echo prompt |
Graphics
| Group | Operators |
|---|---|
| Graphics state (device-independent) | gsave grestore clipsave³ cliprestore³ grestoreall initgraphics gstate² setgstate² currentgstate² setlinewidth currentlinewidth setlinecap currentlinecap setlinejoin currentlinejoin setmiterlimit currentmiterlimit setstrokeadjust² currentstrokeadjust² setdash currentdash setcolorspace² currentcolorspace² setcolor² currentcolor² setgray currentgray sethsbcolor currenthsbcolor setrgbcolor currentrgbcolor setcmykcolor² currentcmykcolor² |
| Graphics state (device-dependent) | sethalftone² currenthalftone² setscreen currentscreen setcolorscreen² currentcolorscreen² settransfer currenttransfer setcolortransfer² currentcolortransfer² setblackgeneration² currentblackgeneration² setundercolorremoval² currentundercolorremoval² setcolorrendering² currentcolorrendering² setflat currentflat setoverprint² currentoverprint² setsmoothness³ currentsmoothness³ |
| Coordinates and matrices | matrix initmatrix identmatrix defaultmatrix currentmatrix setmatrix translate scale rotate concat concatmatrix transform dtransform itransform idtransform invertmatrix |
| Path construction | newpath currentpoint moveto rmoveto lineto rlineto arc arcn arct² arcto curveto rcurveto closepath flattenpath reversepath strokepath ustrokepath² charpath uappend² clippath setbbox² pathbbox pathforall upath² initclip clip eoclip rectclip² ucache² |
| Painting | erasepage stroke fill eofill rectstroke² rectfill² ustroke² ufill² ueofill² shfill³ image colorimage² imagemask |
| Insideness testing | infill² ineofill² inufill² inueofill² instroke² inustroke² |
| Forms and patterns | makepattern² setpattern² execform² |
| Device setup and output | showpage copypage setpagedevice² currentpagedevice² nulldevice |
| Glyphs and fonts | definefont composefont³ undefinefont² findfont scalefont makefont setfont rootfont² currentfont selectfont² show ashow widthshow awidthshow xshow² xyshow² yshow² glyphshow² stringwidth cshow² kshow FontDirectory GlobalFontDirectory² StandardEncoding ISOLatin1Encoding² findencoding² setcachedevice setcachedevice2² setcharwidth |
| Interpreter parameters | setsystemparams² currentsystemparams² setuserparams² currentuserparams² setdevparams² currentdevparams² vmreclaim² setvmthreshold² vmstatus cachestatus setcachelimit setcacheparams² currentcacheparams² setucacheparams² ucachestatus² |
Errors
When an operator fails, the interpreter runs the procedure of that name in
errordict, which by default stops the job and reports the error (through
handleerror).
configurationerror dictfull
dictstackoverflow dictstackunderflow
execstackoverflow handleerror interrupt
invalidaccess invalidexit invalidfileaccess
invalidfont invalidrestore ioerror
limitcheck nocurrentpoint rangecheck
stackoverflow stackunderflow syntaxerror
timeout typecheck undefined
undefinedfilename undefinedresource
undefinedresult unmatchedmark unregistered
VMerror
Filters
| Decode | Encode | Method |
|---|---|---|
ASCIIHexDecode | ASCIIHexEncode | Hex digits. |
ASCII85Decode | ASCII85Encode | Base 85. |
LZWDecode | LZWEncode | LZW compression. |
FlateDecode³ | FlateEncode³ | zlib/deflate compression. |
RunLengthDecode | RunLengthEncode | Byte run lengths. |
CCITTFaxDecode | CCITTFaxEncode | Fax group 3 and 4. |
DCTDecode | DCTEncode | JPEG. |
SubFileDecode | NullEncode | Reads up to an end marker; passes through. |
ReusableStreamDecode³ | – | Buffers data so it can be read again. |
Filters are made with filter and chained, for example
currentfile /ASCII85Decode filter /FlateDecode filter. Filters are
LanguageLevel 2 (table 3.6); in LanguageLevel 3 all encoding filters except
NullEncode became optional.
Colour spaces and resource categories
Colour space families: DeviceGray, DeviceRGB,
DeviceCMYK, CIEBasedA², CIEBasedABC²,
CIEBasedDEF³, CIEBasedDEFG³, Pattern²,
Indexed², Separation², DeviceN³.
Resource categories (LanguageLevel 2 and later): Font,
CIDFont, CMap, FontSet, Encoding,
Form, Pattern, ProcSet,
ColorSpace, Halftone, ColorRendering,
IdiomSet, InkParams, TrapParams,
OutputDevice, ControlLanguage, Localization,
PDL, HWOptions; and implicit categories that list what the
interpreter supports: Filter, ColorSpaceFamily,
Emulator, IODevice, ColorRenderingType,
FMapType, FontType, FormType,
HalftoneType, ImageType, PatternType,
FunctionType, ShadingType, TrappingType, plus
Category and Generic.
LanguageLevel 3 operators in procedure sets
Some LanguageLevel 3 operators live in ProcSet resources rather than
in systemdict (table A.1):
| Procedure set | Operators |
|---|---|
BitmapFontInit | addglyph removeall removeglyphs |
CIDInit | beginbfchar endbfchar beginbfrange endbfrange begincidchar endcidchar begincidrange endcidrange begincmap endcmap begincodespacerange endcodespacerange beginnotdefchar endnotdefchar beginnotdefrange endnotdefrange beginrearrangedfont endrearrangedfont beginusematrix endusematrix StartData usecmap usefont |
ColorRendering | GetHalftoneName GetPageDeviceName GetSubstituteCRD |
FontSetInit | StartData |
Trapping | currenttrapparams settrapparams settrapzone |
Sources
- Adobe, PostScript Language Reference, third edition (1999) – §8.1 operator summary, table 3.6 filters, tables 3.7–3.9 resource categories, §3.11 errors, appendix A (LanguageLevel feature summary and table A.1)