Loading [MathJax]/jax/output/HTML-CSS/jax.js

10 Postscript and PDF

 10.1 Ghostscript
 10.2 GV and Ghostview
 10.3 Acrobat
 10.4 psmerge
 10.5 epsutil
 10.6 prescript and pstotext
 10.7 Postscript to PDF
 10.8 PS Utils
 10.9 Generating Postscript Output

Postscript is a page description language. It was introduced by Adobe Systems in the mid-eighties and has become the standard device independent file format for printing graphics files. What this means is that PostScript describes a graphics image in such a way so that it does not make any reference to specific device features (e.g. printer resolution) so that the same description (postScript file) could be used on any PostScript compatible printer.

An Encapsulated PostScript File (EPSF or EPS) is a PostScript file structured so that it can be incorporated or included into another PostScript file (so that for example a diagram created with a graphics application can be inserted into a text document created with a word processor).

PDF is another page description language introduced by Adobe to replace PostScript, however it isn’t yet in as widespread use as PostScript. For instance its quite hard to find a printer that has a PDF interpreter implemented in hardware, i.e. you can not sent a PDF file directly to the printer but must first convert it to PostScript using display software such as Adobe Acrobat.

10.1 Ghostscript

The Ghostscript software suite is an interpreter for the PostScript language, with the ability to convert PostScript language files to many other formats, display them, and print them on printers that don’t have PostScript language capability built in. Additionally Ghostscript also functions as an interpreter for Portable Document Format (PDF) files, with the much the same capabilities. Finally the suite also contains a C subroutine library (the Ghostscript library) that implements the graphics capabilities that appear as primitive operations in the PostScript language.

There are actually two different versions of Ghostscript, these being the Aladdin and GNU distributions. The main difference between them seems to be the licencing terms, GNU Ghostscript being distributed under the GPL of course with the Aladdin version being distributed under the Aladdin Free Public Licence. The only difference in the licencing terms appears to be that the Aladdin licence does not allow commercial distribution. If you are using Linux you almost certainly have GNU Ghostscript installed due to the licencing issue.

Further information on Ghostscript can be found at http://www.cs.wisc.edu/~ghost/.

10.2 GV and Ghostview

Ghostview is a full fuction X Windows interface for the Ghostscript the PostScript interpreter. Ghostview and Ghostscript function as two cooperating programs. Ghostview creates the viewing window and Ghostscript draws in it. The GUI is fairly self explanatory, however the application ships with an extensive manual page (type man ghostview at the UNIX prompt).

GV is a version of Ghostview that was modified for VMS, some enhancements made, and then modified to run again under Unix. It is now replacing Ghostview as the standard desktop tool for viewing PostScript files, and is in fact the default viewier in most Linux dsitributions (i.e. if you type ghostview on a Linux prompt you’ll probably actually start the GV program instead). An example of GV in action can be seen in Figure 45. Further information on GV and Ghostview can be found at http://www.cs.wisc.edu/~ghost/.


pict

Figure 45: The GV interface.


10.3 Acrobat

Adobe Acrobat Reader allows you to view and print PDF files. While the viewer is free, if you want to create PDF content the tools to do so are not. More information is available at http://www.adobe.com/products/acrobat/readermain.html. The Acrobat reader is distributed as part of the Staarlink baseset software, and can be started by typing acroread.

10.4 psmerge

psmerge is a utility program for merging one or more Encapsulated PostScript Files into a single PostScript file. The input files can be individually rotated, scaled and shifted. The output file can either be Encapsulated PostScript or “normal” PostScript suitable for sending to a printer. The psmerge utility is covered in detail in SUN/164.

10.5 epsutil

epsutil is a utility for manipulating Encapsulated PostScript files. For more information see the manual at http://www.math.utah.edu/~beebe/software/epsutil/epsutil.html.

10.6 prescript and pstotext

prescript extracts text from a PostScript file, storing it either as plain ASCII text, or as HTML according to the mandatory first command-line argument. Usage is:

   prescript [ html plain ] [ input.ps ]

The output file will be given the same base name as the input file, with its file extension set to one of .html or .txt, according to the first command-line argument.

prescript uses a PostScript interpreter, normally gs, to execute the PostScript program, so that even text that is generated programmatically, rather than being explicitly present in PostScript strings, can be extracted. Particular attention is paid to heuristic recognition of word breaks, to reconstruction of words hyphenated at line breaks, to preservation of paragraph breaks, and to recognition of TEXligatures.

The prescript program can be downloaded from http://www.nzdl.org/html/prescript.html.

A possible substitute for prescript is the pstotext utility. More information can be found at http://www.research.digital.com/SRC/virtualpaper/pstotext.html.

10.7 Postscript to PDF

PDF files can be easily generated using the gs utility using the following command.

    gs -q -dSAFER -dNOPAUSE -sPAPERSIZE=a4 -sDEVICE=pdfwrite
       -sOutputFile=output.pdf  input.ps

10.8 PS Utils

PSUtils, written by Angus Duggan, is a collection of useful utilities for manipulating PostScript documents. Programs included are psnup, for placing out several logical pages on a single sheet of paper, psselect, for selecting pages from a document, pstops, for general imposition, psbook, for signature generation for booklet printing, and psresize, for adjusting page sizes.

10.9 Generating Postscript Output

A common task is to take an image, for instance a GIF or JPEG, and generate a PS or EPS output figure for publication. Depending on which package is used for this task there is a suprising difference between the size of the final postscript image. Of the packages available ImageMagick seems to produce the smallest postscript output files due to its use of vectorised postscript rather than bitmaps which other packages (such as xv) use. In extreme cases this can mean the difference between a 2Mb and 50k final postscript file. All the postscript images in this cookbook were generated from the original GIF files using ImageMagick.