 |
Department of Engineering |
 |
 |
Postscript Document Structuring Conventions
Postscript's DSC (Document Structuring Conventions) are lines in the
postscript file that help printers and help programs that need to manipulate
the contents - for example a program like psselect which extracts
pages needs to know where pages begin and end and which parts of the
initialisation are still required. DSC lines begin with '%%' - as can
comment lines! In consequence some applications take DSC lines more
seriously than other applications do - for example, sometimes '%%Orientation: Landscape' is ignored and sometimes it isn't.
Postscript files that follow the conventions should have at least the following
structure
| %!PS-Adobe-3.0 |
| %%Pages: |
| %%EndComments |
| %%BeginProlog |
| %%EndProlog |
| %%BeginSetup |
| %%EndSetup |
|
| %%Page: |
| %%BeginPageSetup |
| %%EndPageSetup |
|
| %%PageTrailer |
|
| %%Trailer |
| %%EOF |
Some applications are a little careless about which section of the file
to put postscript commands in.
- The Prolog shouldn't contain
procedures relevant only to the particular document in question (though
it may contain procedures for all documents produced by a particular
application).
- Page-specific set-up commands should go in a
PageSetup section rather than the Setup section.
Media selection
We have had problems with clashes between options in DSC lines and printing
options given on the command line. In this section we'll look at some
issues relating to A3/A4 paper size selection
lp/lpr/CUPS
Options mentioned in the CUPS documentation to select paper size include
-o media=A4
-o media=Upper
DSC
The options supported in postscript depend on the postscript version.
Before "%%EndComments" you may see a line like
%%DocumentPageSizes: A4
but such lines were superceded in PS-Adobe-3.0 by "%%DocumentMedia", which needs 6 arguments - a string, 3 numbers and 2 strings.
The arguments are: a tag, width, height, weight, paper color, special feature.
0 is used to replace unwanted numbers, and ( ) to replace strings. Examples are
%%DocumentMedia: PlainLetter 612 792 75 white ( )
%%DocumentMedia: Letter 792 612 0 white Plain
The tag string is used
in subsequent "PageMedia" lines which can be in the global defaults
section or the per-page DSC sections. There's also a PaperSize option.
Here are some examples
- The Defaults section
%%BeginDefaults
%%PageMedia: Letter
%%EndDefaults
- The Setup section:
%%BeginSetup
%%PaperSize: A4
%%EndSetup
- Page sections
%%PageMedia: Letter
%%PaperSize: A4
Printers and Viewers
Recent versions of ghostscript will recognise most of the above options, but might have trouble with the per-page options.
Printers will use a default paper tray unless otherwise specified from the command line, but
they'll need to process the postscript page by page to use the correct media type
Here 4 example files (which may not be completely compliant or ideally minimal) that you can use to test your printers.
File 1 - A4 using DocumentMedia
%!PS-Adobe-3.0
%%DocumentMedia: A4 595 842 0 () ()
%%BeginDefaults
%%PageMedia: A4
%%EndDefaults
%%BeginSetup
%%PaperSize: A4
%%EndSetup
%%EndComments
/Times-Roman findfont
15 scalefont
setfont
296 421 moveto
(Testing) show
showpage
|
File 2 - A3 using DocumentMedia
%!PS-Adobe-3.0
%%DocumentMedia: A3 842 1190 0 () ()
%%BeginDefaults
%%PageMedia: A3
%%EndDefaults
%%BeginSetup
%%PaperSize: A3
%%EndSetup
%%EndComments
/Times-Roman findfont
15 scalefont
setfont
421 595 moveto
(Testing) show
showpage
|
File 3 - A4 using setpagedevice
%!PS-Adobe-3.0
%%DocumentPaperSizes: A4
%%EndComments
/setpagedevice where
{ pop 1 dict
dup /PageSize [ 595 842 ] put
setpagedevice
} if
/Times-Roman findfont
15 scalefont
setfont
296 421 moveto
(Testing) show
showpage
|
File 4 - A3 using setpagedevice
%!PS-Adobe-3.0
%%DocumentPaperSizes: A3
%%EndComments
/setpagedevice where
{ pop 1 dict
dup /PageSize [ 842 1190 ] put
setpagedevice
} if
/Times-Roman findfont
15 scalefont
setfont
421 595 moveto
(Testing) show
showpage
|
On our linux/CUPS system with a Canon iR 5570 printer
- Files 1 and 2 come out by default on A4 paper. When lp's
-o media option is used, they're printed on the media requested.
- File 3 comes out on A4 and file 4 comes out on A3 whatever command line options are used.
References