ps2pdf: PostScript-to-PDF converter

Table of contents

For other information, see the Ghostscript overview.


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.


Usage

The usage for ps2pdf is

ps2pdf [options] input.[e]ps output.pdf

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

ps2pdf input.[e]ps

which is equivalent to

ps2pdf input.[e]ps input.pdf

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

All of these scripts actually call a script named ps2pdfwr or ps2pdfxx. The Unix ps2pdfwr script assumes that the Ghostscript executable is named gs; it is unlikely that you will need to change this. The DOS and MS Windows ps2pdfxx.bat script uses the value of the GSC environment variable, if defined, as the name of the executable; otherwise the script assumes the executable is named gswin32c. So in these environments, if the executable has a different name, you must set GSC to the name of the executable.


Options

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. The following may be useful:

-rresolution
Sets the resolution for pattern fills and for fonts that must be converted to bitmaps.
-dProcessColorModel=device_color_space
Sets the color space to be used for device-dependent colors in the output. device_color_space may be /DeviceGray, /DeviceRGB, or /DeviceCMYK; the default value is /DeviceRGB.

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 also recognizes the following switches:

-dPDFSETTINGS=configuration
Presets the "distiller parameters" to one of four predefined settings:

ps2pdf recognizes all of the Acrobat Distiller 4 parameters documented in Adobe Technical Note #5151. Cells in the table containing '=' mean that the value of the parameter is the same as in the "default" column.

Parameter name      Notes    default    screen    printer    prepress

ASCII85EncodePagesfalse===
AlwaysEmbed[]===
AntiAliasColorImages(0)false===
AntiAliasGrayImages(0)false===
AntiAliasMonoImages(0)false===
AutoFilterColorImages(1)true===
AutoFilterGrayImages(1)true===
AutoPositionEPSFiles(0)true===
AutoRotatePages/PageByPage/PageByPage/None/None
Binding(0)/Left===
CalCMYKProfile(0)()===
CalGrayProfile(0)()===
CalRGBProfile(0)()===
CannotEmbedFontPolicy(0)/Warning/Warning/Warning/Error
ColorACSImageDict(note 7)(note 7)(note 8)(note 9)
ColorConversionStrategy(0,6)/LeaveColorUnchanged/sRGB/UseDeviceIndependentColor/LeaveColorUnchanged
ColorImageDepth-1===
ColorImageDict(note 7)===
ColorImageFilter/DCTEncode===
ColorImageDownsampleThreshold1.5===
ColorImageDownsampleType(3)/Subsample/Average/Bicubic/Bicubic
ColorImageResolution7272300300
CompatibilityLevel1.31.21.31.3
CompressPagestrue===
ConvertCMYKImagesToRGBtrue===
ConvertImagesToIndexed(0)true===
CoreDistVersion4000===
CreateJobTicket(0)falsefalsetruetrue
DefaultRenderingIntent/Default===
DetectBlends(0)true===
DoThumbnails(0)falsefalsefalsetrue
DownsampleColorImagesfalsetruefalsefalse
DownsampleGrayImagesfalsetruefalsefalse
DownsampleMonoImagesfalsetruefalsefalse
EmbedAllFontstruefalsetruetrue
EmitDSCWarnings(0)false===
EncodeColorImagestrue===
EncodeGrayImagestrue===
EncodeMonoImagestrue===
EndPage(0)-1===
GrayACSImageDict(note 7)(note 7)(note 8)=
GrayImageDepth-1===
GrayImageDict(note 7)===
GrayImageDownsampleThreshold1.5===
GrayImageDownsampleType(3)/Subsample/Average/Bicubic/Bicubic
GrayImageFilter/DCTEncode===
GrayImageResolution7272300300
ImageMemory(0)500000===
LockDistillerParamsfalse===
LZWEncodePages(2)false===
MaxSubsetPct100===
MonoImageDepth-1===
MonoImageDict<>===
MonoImageDownsampleThreshold1.5===
MonoImageDownsampleType/Subsample/Average/Bicubic/Bicubic
MonoImageFilter/CCITTFaxEncode===
MonoImageResolution30030012001200
NeverEmbed[]===
OPM1===
Optimize(0,5)falsetruetruetrue
ParseDSCCommentstrue===
ParseDSCCommentsForDocInfotruefalsetruetrue
PreserveCopyPage(0)true===
PreserveEPSInfo(0)true===
PreserveHalftoneInfofalse===
PreserveOPIComments(0)falsefalsetruetrue
PreserveOverprintSettingsfalsefalsetruetrue
sRGBProfile(0)()===
StartPage(0)1===
SubsetFontstrue===
TransferFunctionInfo(4)/Preserve===
UCRandBGInfo/Remove/Remove/Preserve/Preserve
UseFlateCompressiontrue===
UsePrologue(0)false===

(note 0) This parameter can be set and queried, but currently has no effect.

(note 1) AutoFilterxxxImages doesn't examine the image to decide between JPEG and LZW or Flate compression: it uses JPEG compression if the image has 8 bits per component and does not use an Indexed color space, and LZW or Flate compression otherwise.

(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.

(note 3) The xxxDownsampleType parameters can also have the value /Bicubic (a Distiller 4 feature), which is currently treated as equivalent to /Average.

(note 4) Currently, the transfer function is always applied. If the corresponding parameter is set to /Preserve, the function setting is also copied into the PDF file.

(note 5) Optimization (linearization) is implemented with a separate program, pdfopt input.pdf output.pdf; the Optimize parameter has no effect.

(note 6) Currently, colors for images and shadings are left in the color space specified in the PostScript input, except for ConvertCMYKImagesToRGB; the current color in the graphics state (used for fill, stroke, text, and imagemask) is always converted to the color space specified by the current value of ProcessColorModel. The intended behavior is the same as for Acrobat Distiller, except that if ColorConversionStrategy is set to /UseDeviceDependentColor, colors are converted to the color space specified by ProcessColorModel rather than always to /DeviceRGB.

(note 7) The default image parameter dictionary is

<< /QFactor 0.9 /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] >>

(note 8) The printer ACS image parameter dictionary is

<< /QFactor 0.55 /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] >>

(note 9) The prepress ACS image parameter dictionary is

<< /QFactor 0.25 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>

Limitations

ps2pdf will sometimes convert text to high-resolution bitmapped fonts rather than to embedded outline fonts. This will occur when the PostScript file uses Type 3, CIDFontType 1, or CIDFontType 4 fonts, or Type 0 fonts that reference any of these; it may also occur in some cases if the input file uses fonts with non-standard encodings, or in some other rare cases.

The PDF output always represents the colors of text and graphics in DeviceGray or DeviceRGB color space (or DeviceCMYK if the ProcessColorModel parameter has been set to /DeviceCMYK); 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.

Some applications, such as HIGZ, produce PostScript files that use ridiculously large coordinates. On such files, ps2pdf may cause a limitcheck error. If this occurs, try reducing the default internal resolution of 720 dpi by using the -r switch, e.g., ps2pdf -r300 somefile.ps.

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.

ps2pdf currently has only very limited support for PDF 1.4. It writes out the blend mode, constant alpha, and text knockout graphics state parameters, and it handles images with soft masks, but it does not handle transparency groups, or soft masks in the graphics state. (Note that there is no standard way to specify any of these things in PostScript, so these statements only apply when the input file is already a PDF 1.4 file.)


Known problems

Distiller parameters should only be saved by save and restored by restore, but they are also saved by 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.

If the input file downloads Type 1 fonts incrementally, the output file may contain embedded fonts with some information missing from the FontDescriptor, which may crash Acrobat Reader 4 or produce incorrect character spacing.


Comparison of ps2pdf and Acrobat Distiller

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.

ps2pdf usually produces output that is comparable in size to the output of Acrobat Distiller; however, it sometimes produces much larger output, especially if the input file involves pattern fills.

Many users report that the combination of ps2pdf with Acrobat Reader 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.


Acknowledgments

Thanks to George N. White III <aa056@chebucto.ns.ca> 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 <http://www.sil.org> for help with testing ps2pdf with a wide variety of international fonts.


Copyright © 1996, 2000 Aladdin Enterprises. All rights reserved.

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

Ghostscript version 7.03, 20 October 2001