[texhax] postscript printing
Reinhard Kotucha
reinhard.kotucha at web.de
Fri Jun 25 03:07:06 CEST 2004
>>>>> "tom" == tom sgouros <tomfool at as220.org> writes:
> If anyone on the list wanted to clarify the distinction for the
> benighted among us, I, for one, would be interested and
> grateful.
A PS file describes one or more pages. Here is a simple example:
----------------------------------
%!
/Palatino 50 selectfont
/inch { 72 mul } def
1 inch 1 inch moveto 2 inch 2 inch lineto
5 setlinewidth stroke
showpage
100 200 moveto
(Hello) show
showpage
----------------------------------
You can send this file to a printer and whenever a "showpage" occurs,
a page is ejected.
The first line is mandatory. Some programs (which do expect
PostScript input only) may work without it, but a printer needs it to
decide whether to treat it as a PS or plain ASCII file.
People sometimes do not want to print the whole document but only
particular pages. This can be done by some PostScript code which
redefines showpage in such a way that it counts how often it is called
and behaves like showpage on the pages you want to print and like
erasepage on pages you want to omit.
This piece of code must be inserted at the begin of the document just
after the first line.
This is quite difficult and error-prone. People want to extract pages
without dealing with PostScript code using external programs.
Therefore Adobe introduced the so-called "document structured
comments" (DSC).
Comments in PS look like comments in TeX, they also begin with a
percent character and the interpreter ignores everything until the end
of the line.
A DSC begins with two percent characters at the very beginning of a
line and may not contain arbitrary text.
Here is a very simplified example of the file using DSCs. It doesn't
work, but shows the idea:
----------------------------------
%!PS-Adobe-2.0
%%BeginProlog
/Palatino 50 selectfont
/inch { 72 mul } def
%%EndProlog
%%Page 1
1 inch 1 inch moveto 2 inch 2 inch lineto
5 setlinewidth stroke
showpage
%%Page 2
100 200 moveto
(Hello) show
showpage
%%EOF
----------------------------------
A program can now extract a page without the need to understand
PostScript code. It just has to understand the DSCs. It's quite easy
to extract the content of a page now. The stuff betweeen
%%BeginProlog and %%EndProlog is prepended to each set of pages
selected for printing.
BTW., the first line now describes the version number of the DSC
standard used in this document.
The example is too much simplified and wrong but you can get the
description at:
http://partners.adobe.com/asn/developer/pdfs/tn/5001.DSC_Spec.pdf
You now know what DSCs are, so we can discuss EPS.
Sometimes people want to create PostScript graphics and put them into
other documents. Therefore Adobe invented the "Encapsulated
PostScript" standard. An EPS file looks very similar to a PS file,
but there are some restrictions:
Obviously an EPS should describe a single page. A PS file can
instruct a printer to select a particular paper tray. Those
instrictions are disallowed in EPS files.
A program like TeX which wants to include a PostScript graphic must
know how large it is and where it is located. PostScript does not
force people to place graphics at the origin of a page.
The EPS standard introduces a special DSC "%%BoundingBox" which
provides the coordinates of the lower left and the upper right corner
of the graphic.
This is the most important thing of an EPS file. It looks like:
%%BoundingBox: 20 25 122 200
You'll find a detailed description of the EPS standard at
http://partners.adobe.com/asn/developer/pdfs/tn/5002.EPSF_Spec.pdf
However, many programs provide a wrong BoundingBox. Especially under
Widows it is quite unlikely that you get something useful.
Some programs produce usual PS files (one or more pages) and add a
comment like:
%%BoundingBox: 0 0 595 842
This is good for nothing, it just describes A4 paper.
LaTeX doesn't understand PostScript at all. The command
\includegraphics{abc.ps} just causes LaTeX to read abc.ps and search
for a line beginning with %%BoundingBox.
It then inserts an empty box with the appropriate size to the document
to reserve space for the graphic.
The coordinates and the filename (and probably some information about
scaling) are put into the dvi file.
The only thing LaTeX is interested in is the %%BoundingBox comment.
Everything else has to be done by postprocessors like xdvi or dvips.
If you are interested in PostScript in general, I recommand the book
"PostScript by Example" by Henry McGilton and Mary Campione, Addison
Wesley 1992, ISBN 0-201-63228-4.
It provides a step-by-step introduction to PostScript. It does not
even require that the reader knows what a programming language is.
Programmers might prefer the PostSript Language Reference Manual:
http://partners.adobe.com/asn/developer/pdfs/tn/psrefman.pdf
Regards,
Reinhard
--
----------------------------------------------------------------------------
Reinhard Kotucha Phone: +49-511-4592165
Marschnerstr. 25
D-30167 Hannover mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------
More information about the texhax
mailing list