PostScript language

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

PostScript language

[edit]
PostScript is a page description language run in an interpreter to generate an image.[6] It
can handle graphics and has standard features of programming languages such
as branching and looping.[6] PDF is a subset of PostScript, simplified to remove
such control flow features, while graphics commands remain.[6]

PostScript was originally designed for a drastically different use case: transmission of
one-way linear print jobs in which the PostScript interpreter would collect a series of
commands until it encountered the showpage command, then execute all the commands
to render a page as a raster image to a printing device.[17] PostScript was not intended
for long-term storage and real-time interactive rendering of electronic
documents to computer monitors, so there was no need to support anything other than
consecutive rendering of pages.[17] If there was an error in the final printed output, the
user would correct it at the application level and send a new print job in the form of an
entirely new PostScript file. Thus, any given page in a PostScript file could be
accurately rendered only as the cumulative result of executing all preceding commands
to draw all previous pages—any of which could affect subsequent pages—plus the
commands to draw that particular page, and there was no easy way to bypass that
process to skip around to different pages.[17]

Traditionally, to go from PostScript to PDF, a source PostScript file (that is, an


executable program) is used as the basis for generating PostScript-like PDF code (see,
e.g., Adobe Distiller). This is done by applying standard compiler techniques like loop
unrolling, inlining and removing unused branches, resulting in code that is purely
declarative and static.[17] The end result is then packaged into a container format,
together with all necessary dependencies for correct rendering (external files, graphics,
or fonts to which the document refers), and compressed. Modern applications write to
printer drivers that directly generate PDF rather than going through PostScript first.

As a document format, PDF has several advantages over PostScript:

 PDF contains only static declarative PostScript code that can be processed as data,
and does not require a full program interpreter or compiler.[17] This avoids the
complexity and security risks of an engine with such a higher complexity level.
 Like Display PostScript, PDF has supported transparent graphics since version 1.4,
while standard PostScript does not.
 PDF enforces the rule that the code for any particular page cannot affect any other
pages.[17] That rule is strongly recommended for PostScript code too, but has to be
implemented explicitly (see, e.g., the Document Structuring Conventions), as
PostScript is a full programming language that allows for such greater flexibilities
and is not limited to the concepts of pages and documents.
 All data required for rendering is included within the file itself, improving portability. [18]
Its disadvantages are:
 A loss of flexibility, and limitation to a single use case.[citation needed]
 A (sometimes much) larger file size.[19]
PDF since v1.6 supports embedding of interactive 3D documents: 3D drawings can be
embedded using U3D or PRC and various other data formats.[20][21][22]

File format
[edit]
A PDF file is organized using ASCII characters, except for certain elements that may
have binary content. The file starts with a header containing a magic number (as a
readable string) and the version of the format, for example %PDF-1.7. The format is a
subset of a COS ("Carousel" Object Structure) format.[23] A COS tree file consists
primarily of objects, of which there are nine types:[16]

 Boolean values, representing true or false


 Real numbers
 Integers
 Strings, enclosed within parentheses ((...)) or represented as hexadecimal within
single angle brackets (<...>). Strings may contain 8-bit characters.
 Names, starting with a forward slash (/)
 Arrays, ordered collections of objects enclosed within square brackets ([...])
 Dictionaries, collections of objects indexed by names enclosed within double angle
brackets (<<...>>)
 Streams, usually containing large amounts of optionally compressed binary data,
preceded by a dictionary and enclosed between
the stream and endstream keywords.
 The null object

You might also like