ps2pdf: PostScript-to-PDF converter

Table of contents

For other information, see the Ghostscript overview.


ps2pdf is a work-alike for nearly all the functionality (but not the user interface) of Adobe's AcrobatTM DistillerTM product: it converts PostScript files to Portable Document Format (PDF) files.

ps2pdf is implemented as a very small command script (batch file) that invokes Ghostscript, selecting a special "output device" called pdfwrite. In order to use ps2pdf, the pdfwrite device must be included in the makefile when Ghostscript was compiled; see the documentation on building Ghostscript for details: this is currently the case on all platforms, in Ghostscript as we distribute it.


The usage for ps2pdf is

ps2pdf [options] output.pdf

or, on Unix systems and some versions of Windows NT and OS/2


which is equivalent to

ps2pdf input.pdf

There are actually three different ps2pdf* scripts: the name ps2pdf above refers to any of them.

All of these scripts actually call a script named ps2pdfwr. Normally, you will not need to do anything with this script. The Unix ps2pdfwr script assumes that the Ghostscript executable is named gs; the DOS and MS Windows ps2pdfwr.bat script assumes the executable is named gswin32c. On DOS or MS Windows, if the executable has a different name, you must edit the ps2pdfwr.bat script file: look for the line that says

set PS2PDFGS=gswin32c

and change it to

set PS2PDFGS=executable_name


The options in the command line may include any switches that may be used with Ghostscript's PostScript and PDF interpreter (see here for a complete list), although almost none of them are useful with ps2pdf. More importantly, options may include -dparameter=value or -sparameter=string switches for setting "distiller parameters", Adobe's documented parameters for controlling the conversion process. The PostScript setdistillerparams and currentdistillerparams operators are also recognized when running ps2pdf, and provide an equivalent way to set these parameters from within the PostScript input file.

ps2pdf recognizes all of the Acrobat Distiller 3 parameters documented in Adobe Technical Note #5151 except for the ImageDict parameters, but only a subset have an effect:

Parameter name    Initial value      Notes

MonoImageDict<< >>

(note 1) AutoFilterxxxImages doesn't examine the image to decide between JPEG and LZW/Flate compression: it always uses LZW/Flate compression.

(note 2) Because of Unisys's threats regarding the Welch patent, ps2pdf cannot actually use LZW compression: instead, it treats all requests for LZW compression as calling for Flate compression if UseFlateCompression is true and CompatibilityLevel >= 1.2, and ignores them otherwise.

The remaining Distiller 3 parameters are defined and can be set and queried, but do not have any effect:

Parameter name    Initial value

ColorACSImageDict<< >>
ColorImageDict<< >>
GrayACSImageDict<< >>
GrayImageDict<< >>

ps2pdf does not implement the Acrobat Distiller 4 parameters. Settings for these parameters will be ignored, except that setting the EndPage parameter will cause an error.


In some situations, ps2pdf will convert text to high-resolution bitmapped fonts rather than to embedded outline fonts. Currently, this will always occur when the PostScript file uses CID-keyed or double-byte fonts, or in some cases if it uses fonts with non-standard encodings; it may occur in other cases as well.

The PDF output always represents the colors of text and graphics in DeviceGray or DeviceRGB color space; all other color spaces are converted to these. However, for images, it will retain the original color space for DeviceGray, DeviceRGB, DeviceCMYK, certain CIEBased spaces, and Indexed spaces based on these.

ps2pdf will sometimes convert PostScript constructs to lower-level ones, even if a higher-level construct is available. For example, if the PostScript file uses charpath to set a clipping path consisting of text, ps2pdf will write the clipping path as a path in the PDF file, rather than as text, even though PDF is able to express clipping with text. This is only a performance issue, and will be improved incrementally over time.

ps2pdf ignores the PDF 1.3 (Acrobat 4.x) pdfmarks related to document content structure: StRoleMap, StClassMap, StPNE, StBookmarkRoot, StPush, StPop, StPopAll, StBMC, StBDC, EMC, StOBJ, StAttr, StStore, StRetrieve, NamespacePush, NamespacePop, and NI. While this causes some structural information to be omitted from the output file, the displayed and printed output are normally not affected.

Known problems

Distiller parameters should only be saved by save and restored by restore, but they are also saved gsave and restored by grestore.

Changing the value of the CompressPages parameter after any marks have been made on the page may cause a crash.

Setting a value for the ColorACSImageDict, ColorImageDict, GrayACSImageDict, or GrayImageDict parameter will probably cause a crash.

Benefits of using ps2pdf

According to users, the greatest benefit of ps2pdf is that it is more robust than Acrobat Distiller: it will process complex and difficult PostScript files that Acrobat Distiller is not able to handle.

For certain documents, ps2pdf is much faster than Adobe Distiller, and may be suitable for run-time conversions. George White, a heavy user of ps2pdf, remarks:

I haven't seen a head to head comparison, but Distiller seems slower when running on what should be a faster system (for instance, Distiller on a PPC Mac vs a 25 MHz 68040 NeXT running ps2pdf), so I think this is fair -- also, one of Mark Doyle's postings indicated that Distiller was not fast enough for use as a run-time server. In contrast, I find that I can use ps2pdf as a post-processor during routine document creation.

On the other hand, there are some documents for which ps2pdf may be much slower than Acrobat Distiller. Caveat user.

Many users report that the combination of ps2pdf with Acrobat is superior to using a generic PostScript viewer (psview or ghostview), particularly for documents with many pages where the navigational support in PDF files reduces the overhead involved in navigating conventional PostScript documents.


Thanks to George N. White III <> of the Ocean Sciences Division of the Bedford Institute of Oceanography in Dartmouth, Nova Scotia for extensive testing of early versions of ps2pdf, and for contributing most of this writeup.

Thanks to Martin Hosken of SIL International <> for help with testing ps2pdf with a wide variety of international fonts.

Copyright © 1996, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.

This file is part of Aladdin Ghostscript. See the Aladdin Free Public License (the "License") for full details of the terms of using, copying, modifying, and redistributing Aladdin Ghostscript.

Ghostscript version 6.0, 3 February 2000