logo_90
Uni ZH | Informatikdienste | PostScript
  1. The PostScript Program Structure
  2. Document Structuring Conventions (DSC)

1. The PostScript program structure

PSHEAD
The PostScript language itself does not specify the overall structure of a PostScript program. For a PostScript program that is a page description (i.e., a description of a printable document), it is advantageous to impose an overall program structure.
  1. It is recommended that a page description consists of a prolog with the definitions and a script that describes the elements of the page.
  2. A script of a multi-page document is organized as a sequence of independent single-page descriptions, bracketed by save - restore operators. These operators do save and restore the current state of the virtual memory in the printing system.
The occurrence of the character "%" signifies a comment. When the showpage operator is specified after the restore operator, #copies of the printed page are output.
                                                               
%!PS-Adobe-1.0
%%Creator: Peter
%%Title: typesetter independent troff
%%Pages: 2
%%DocumentFonts: Helvetica Helvetica-Bold
%%BoundingBox: 0 0 612 792
%%EndComments
/#copies 1 def
   ... prologue ...
/m /moveto load def   % defining a motion
/s /show load def     % defining a string output
   ...
                      % defining ...
   ...
%%EndProlog
 
%%Page: 1 1
   /saveobj save def
   ... page script ...                                                    
   saveobj restore
   showpage
 
%%Page: 2 2
   /saveobj save def
   ... page script ...
   saveobj restore
   showpage
%%Trailer
The comment lines beginning with "%%" are discarded by the PostScript interpreter, but give the so-called "Document Structuring Conventions" information.

2. Document Structuring Conventions (DSC)

Die Kommentar-Zeilen, die mit "%%" beginnen und die sog. "Document Structuring Conventions" enthalten, werden vom PostScript-Interpreter nicht beachtet. Die Konventionen erlauben es, die Struktur einer Illustration oder einer Seitenbeschreibung zu erkennen, ohne das gesamte PostScript-Programm interpretieren oder ausführen zu müssen.

Der Kommentar "%%EndProlog" markiert das Ende des Prologs mit den Definitionen und den Beginn der Seitenbeschreibungen. Der Kommentar "%%Page:", der eine einzelne Seitenbeschreibung angibt, zählt die entsprechende Seitennummer auf. Der Page-Kommentar kommt nur in (mehrseitigen) Druckfiles vor, nicht jedoch in einem EPS-File, welches eine einzelne Illustration beschreibt.

Die neue Version 3.0 der Document Structuring Conventions kennt das Konzept der Ressourcen (eigene Fonts, Prozeduren, usw.). Der Prolog besteht dabei aus verschiedenen Ressourcen, die jeweils von den DSC-Kommentaren "%%BeginResource:" und "%%EndResource" eingeklammert sind. Beispiel aus PostScript Level 2:

%%BeginResource: halftone NXLaserPrinter
   ... Halbton-Definition ...		 		 
%%EndResource
%%BeginResource: colorspace NXCalibratedRGB
   ... Farbraum ...
%%EndResource
%%BeginResource: procset EUROPATTERN 0 0
   ... Fuellmuster ... 
%%EndResource
Wenn eine Ressource nicht im Prolog enthalten ist, muss sie importiert werden. Beispiel:
%%IncludeResource: font Korinna-Regular
Dies ist Aufgabe des Druck-Managers. Leider halten sich noch lange nicht alle PostScript-Treiber an die neue DSC-Version 3.0.

Encapsulated PostScript File

Ein EPS-File ist ein PostScript-Programm, welches das Aussehen einer einzelnen Seite beschreibt. Der Zweck des EPS-Files ist es normalerweise, von einer anderen PostScript-Seitenbeschreibung importiert oder eingebettet zu werden. Das EPS-File kann eine beliebige Kombination von Text, Grafik und Bild enthalten. Mit einigen Einschränkungen ist das EPS-File gleich einem PostScript-File.

Normally, you can import your ps-file as eps-file, provided that your PostScript file is describing one illustration only (must not be a multi-page file). AND provided that your file begins with the following two PostScript comments:

%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 600 300
where BoundingBox gives the lower left and the upper right corner of your illustration (in points). This information enables an importing application to place and resize your illustration.

In addition, an eps file must not contain some "dangerous" PostScript operators. Some operators to avoid: initgraphics, erasepage, setpageparams, exitserver, etc. You may find the complete EPS specification in the PostScript Reference Language, by Adobe Systems.

Fundamentally, an Encapsulated PostScript File is merely a standard PostScript file with a bitmap screen dump OPTIONALLY included in the file.


Uni ZH | Informatikdienste | PostScript
Optimized for Lynx Last update: Tuesday, 02-Apr-2002 13:48:22 CEST by vo