Postscript Operators 'p'

packedarray any0 ... anyn-1 n packedarray packedarray LEVEL 2

creates a packed array object of length n containing the objects any0 through anyn-1 as elements. packedarray first removes the non-negative integer n from the operand stack. It then removes that number of objects from the operand stack, creates a packed array containing those objects as elements, and finally pushes the resulting packed array object on the operand stack.

The resulting object has a type of packedarraytype, a literal attribute, and readonly access. In all other respects, its behavior is identical to that of an ordinary array object.
v The packed array is allocated in local or global VM according to the current VM allocation mode. An invalidaccess error occurs if the packed array is in global VM and any of any0 ... anyn-1 are in local VM.

ERRORS: invalidaccess, rangecheck,

stackunderflow, typecheck,


SEE ALSO: aload

Troubleshooting index Back to Postscript index

pathbbox - pathbbox llx lly urx ury

returns the bounding box of the current path in the current user coordinate system. The results are four real numbers: lower-left x, lower-left y, upper-right x, and upper-right y. These coordinates describe a rectangle, oriented with its sides parallel to the x and y axes in user space, that completely encloses all elements of the path. If the current path is empty, pathbbox executes the error nocurrentpoint.

pathbbox first computes the bounding box of the current path in device space. It then transforms these coordinates to user space by the inverse of CTM and computes the bounding box of the resulting figure in user space. If the user coordinate system is rotated (other than by multiples of 90 degrees) or skewed, pathbbox may return a bounding box that is larger than expected.

If the path includes curve segments, the bounding box encloses the control points of the curves as well as the curves themselves. To obtain a bounding box that fits the path more tightly, one should first "flatten" the curve segments by executing flattenpath.

In Level 2 implementations of the PostScript language, if the current path ends with a moveto, the bounding box does not necessarily include it, unless the moveto is the only element of the path. If an explicit bounding box has been established by setbbox, pathbbox returns a result derived from that bounding box, not from the actual path.

ERRORS: nocurrentpoint, stackoverflow

SEE ALSO: flattenpath, clippath,

charpath, setbbox

Troubleshooting index Back to Postscript index

pathforall move line curve close pathforall
- removes four operands from the stack, all of which must be procedures. pathforall then enumerates the current path in order, executing one of the four procedures for each element in the path. The four basic kinds of elements in a path are moveto, lineto,

curveto, and closepath. The relative variants rmoveto, rlineto, and rcurveto are converted to the corresponding absolute forms; arc, arcn, and arcto are converted to sequences of curveto. For each element in the path, pathforall pushes the element's coordinates on the operand stack and executes one of the four procedures as follows:

moveto push x y; execute move
lineto push x y; execute line
curveto push x1 y1 x2 y2 x3 y3; execute curve
closepath execute close

The operands passed to the procedures are coordinates in user space. pathforall transforms them from device space to user space using the inverse of the CTM. Ordinarily, these coordinates will be the same as the ones originally entered by moveto, lineto, and so forth. However, if the CTM has been changed since the path was constructed, the coordinates reported by pathforall will be different from those originally entered.

Among other uses, pathforall enables a path constructed in one user coordinate system to be read out in another user coordinate system.

pathforall enumerates the current path existing at the time it begins execution. If any of the procedures change the current path, such changes do not alter the behavior of pathforall.

If charpath was used to construct any portion of the current path from a font whose outlines are protected, pathforall is not allowed. Its execution will produce an invalidaccess error (see charpath).

ERRORS: invalidaccess, stackoverflow,

stackunderflow, typecheck

SEE ALSO: moveto, lineto,

curveto, closepath,


Troubleshooting index Back to Postscript index

pop any pop
- removes the top element from the operand stack and discards it.


1 2 3 pop -> 1 2
1 2 3 pop pop -> 1

ERRORS: stackunderflow

SEE ALSO: clear, dup

Troubleshooting index Back to Postscript index

print string print
- writes the characters of string to the standard output file. The print operator provides the simplest means to send text to an application or an interactive user. Note that print is a file operator that has nothing to do with painting character shapes on the current page (see show) or with sending the current page to a raster output device (see showpage).

ERRORS: invalidaccess, ioerror,

stackunderflow, typecheck

SEE ALSO: write, flush,

=, ==,


Troubleshooting index Back to Postscript index

printobject obj tag printobject - LEVEL 2
writes a binary object sequence to the standard output file. The binary object sequence contains a top-level array whose length is one; its single element is an encoding of obj. If obj is composite, the binary object sequence also includes subsidiary array and string values for the components of obj.
The tag operand, which must be an integer in the range 0 to 255, is used to tag the top-level object; it appears as the second byte of the object's representation.
Tag values 0 through 249 are available for general use;
tag values 250 through 255 are reserved for special purposes, such as reporting errors.

The binary object sequence uses the number representation established by the most recent execution of setobjectformat. The token type given as the first byte of the binary object sequence reflects the number representation that was used. If the object format parameter has been set to zero, printobject executes an undefined error.

The object obj and its components must be of type null, integer, real, name, boolean, string, array, or mark. Appearance of an object of any other type, including packed array, will result in a typecheck error. If arrays are nested too deeply or are cyclical, a limitcheck error occurs.

printobject always encodes a name object as a reference to a text name in the string value portion of the binary object sequence, never as a system or user name index.

As is the case for all operators that write to files, the output produced by printobject may accumulate in a buffer instead of being transmitted immediately. To ensure immediate transmission, a flush is required. This is particularly important in situations where the output produced by printobject is the response to a query from the application.

ERRORS: invalidaccess, ioerror,

limitcheck, rangecheck,

stackunderflow, typecheck,


SEE ALSO: print, setobjectformat,


Troubleshooting index Back to Postscript index

product - product string LEVEL 2
is a read-only string object that is the name of the product in which the PostScript interpreter is running. The value of this string is typically a manufacturer defined trademark; it has no direct connection with specific features of the PostScript language.

ERRORS: stackoverflow

SEE ALSO: languagelevel, revision,

serialnumber, version

Troubleshooting index Back to Postscript index

prompt - prompt
- is a procedure executed by executive whenever it is ready for the user to enter a new statement. The standard definition of prompt is "(PS>) print flush" and is defined in systemdict; it can be overridden by defining prompt in userdict or some other dictionary higher on the dictionary stack. prompt is not defined in products that do not support executive.

ERRORS: (none)

SEE ALSO: executive

Troubleshooting index Back to Postscript index

pstack any1 ... anyn pstack any1 ... anyn
writes text representations of every object on the stack to the standard output file, but leaves the stack unchanged. pstack applies the == operator to each element of the stack, starting with the topmost element. See the == operator for a description of its effects.

ERRORS: (none)

SEE ALSO: stack, =,


Troubleshooting index Back to Postscript index

put array index any put -
dict key any put -
string index int put -

replaces a single element of the value of an array, dictionary, or string.

If the first operand is an array or string, put treats the second operand as an index and stores the third operand at the position identified by the index, counting from zero. index must be in the range 0 to n-1,where n is the length of the array or string. If it is outside this range, put will execute a rangecheck error.

If the first operand is a dictionary, put uses the second operand as a key and the third operand as a value, and it stores this key-value pair into dict. If key is already present as a key in dict, put simply replaces its value by any. Otherwise, put creates a new entry for key and associates any with it. In Level 1 implementations, if dict is already full, put executes the error dictfull.

If the value of array or dict is in global VM and any is a composite object whose value is in local VM, an invalidaccess error occurs.


/ar [5 17 3 8] def
ar 2 (abcd) put
ar -> [5 17 (abcd) 8]

/d 5 dict def
d /abc 123 put
d /{

} forall -> /abc 123

/st (abc) def
st 0 65 put % 65 is ASCII code for character "A"
st -> (Abc)

ERRORS: dictfull, invalidaccess,

rangecheck, stackunderflow,


SEE ALSO: get, putinterval

Troubleshooting index Back to Postscript index

putinterval array1 index array2 putinterval -
array1 index packedarray2 putinterval -
string1 index string2 putinterval -

replaces a subsequence of the elements of the first operand by the entire contents of the third operand. The subsequence that is replaced begins at the specified index in the first operand; its length is the same as the length of the third operand.

The objects are copied from the third operand to the first, as if by a sequence of individual gets and puts. In the case of arrays, if the copied elements are themselves composite objects, the values of those objects are shared between array2 and array1.

putinterval requires index to be a valid index in array1 or string1 such that index plus the length of array2 or string2 is not greater than the length of array1 or string1.

If the value of array1 is in global VM and any of the elements copied from array2 or packedarray2 are composite objects whose values are in local VM, an invalidaccess error occurs.


/ar [5 8 2 7 3] def
ar 1 [(a) (b) (c)] putinterval
ar -> [5 (a) (b) (c) 3]

/st (abc) def
st 1 (de) putinterval
st -> (ade)

ERRORS: invalidaccess, rangecheck,

stackunderflow, typecheck

SEE ALSO: getinterval, put

Troubleshooting index Back to Postscript index

Original file name: PSL2p.html