ps2ps2: Converts Postscript Level 3 or PDF into Postscript Level 2

Table of contents

For other information, see the Ghostscript overview.


ps2ps2 is a script for converting a PDF or Language Level 3 PostScript into Postscript Language Level 2.

ps2ps2 is implemented as a very small command script (batch file) that invokes Ghostscript, selecting a special "output device" called ps2write. In order to use ps2ps2, the ps2write 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 ps2ps2 is

ps2ps2 [options] input.{ps|eps|pdf}


The options given on the command line may include any switches valid for use with Ghostscript's PostScript and PDF interpreter (see here for a complete list).

Some input features (eg PDF transparency) cannot be reproduced in level 2 PostScript, and in these case the ps2write device will render the affected area (or page) to a bitmap image. In this case the Output resolution affcts the size and quality of the rendered image, therefore we strongly recommend setting this value appropriately for the target printer or other output device.

Important : If PostScript level 2 can't handle a particular font type, ps2write converts the fonts into a bitmap fonts representation, using the resolution specified when ps2write is invoked. In particular this can happen with CID fonts, which are not Postscript Level 2 objects. In general these are converted to multiple instances of other font types)

More importantly, options passed to ps2ps2 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 ps2ps2, and provide an equivalent way to set these parameters from within the PostScript input file.

The ps2write device handles the same set of distiller parameters as are handled by the pdfwrite device (and 2 unique extensions, see below). See the PostScript-to-PDF converter documentation for a complete description of how to use them to control the document conversion.

The following options may be important for ps2ps2 due to the target interpreter features:

See PostScript-to-PDF converter for details. The option -dMaxInlineImageSize=integer must not be used with ps2ps2.

This set includes all of the Acrobat Distiller 5 parameters defined in the DistillerParameters document included in the Acrobat SDK. Default values are same as the printer settings defined in PostScript-to-PDF converter, with these exceptions:

/PreserveHalftoneInfo true,
/TransferFunctionInfo /Preserve,
/CompressPages true,
/CompressFonts true,
/ASCII85EncodePages true,

There are also two additional (not Adobe-standard) Distiller parameters, specific to ps2write:

/PSDocOptions string
No default value. If defined, the contents of the string will be emitted in the output PostScript prolog enclosed within %%BeginSetup and %%EndSetup comments. This is intended as a means of introducing device-specific document wide setup or configuration options into the output. Default media selection, printer resolution etc might be included here.
/PSPageOptions array of strings
No default value. If defined, the contents of the strings in the array will be emitted in the output PostScript at the start of each page, one string per page, enclosed within %%BeginPageSetup and %%EndPageSetup comments. This is intended as a means of introducing device-specific setup or configuration options into the output on a page by page basis. The strings are used from the array sequentially, if there are more pages than strings then we 'wrap round' and start again with the first string. This makes it convenient to do setup for even/odd pages by simply including 2 strings in the array.

NB the strings contained in PSDocOptions, and the PSPageOptions array, are written verbatim to the output. No error checking is (or can be) performed on these strings and it is the users responsibility to ensure they contain well formed PostScript which does not cause errors on the target device.

There are also the following ps2write specific options :

Default value is true. When this value is true the output PostScript file will be constructed in a way which is compatible with the Adobe Document Structuring Convention, and will include a set of comments appropriate for use by document managers. This enables features such as page extraction, N-up printing and so on to be performed. When set to false, the output file will not be DSC-compliant. Older versions of Ghostscript cannot produce DSC-compliant output from ps2write, and the behviour for these older versions matches the case when ProduceDSC is false.
When this parameter is true, the LZWEncode and ASCII85Encode filters will be applied to the entire output file. In this case CompressPages should be false to prevent a dual compression. When this parameter is false, these filters will be applied to the initial procset only, if CompressPages is true. Default value is false.

Note: It is not possible to set CompressEntireFile when ProduceDSC is true as a single compressed object cannot conform to the DSC. It is possible to set CompressPages which will also compress the ps2write ProcSet.

Controlling device-specific behavior

A few options can be used to influence the behavior of a printer or PostScript interpreter that reads the result of ps2ps2. All of these options are incompatible with DSC-compliant PostScript, in order to use any of them ProduceDSC must be set to false.

The printer will rotate pages for a better fit with the physical size. Default value : false. Must be false if -dSetPageSize=true.
The printer will scale pages down to better fit the physical page size. The rendering quality may be poor due to the scaling, especially for fonts which Ghostscript had converted into bitmaps (see the ps2write device parameter HaveTrueTypes; See Options about the PageSize entry of the Policies dictionary while the conversion step). Default value : false. Must be false if -dSetPageSize=true or -dCenterPages=true.
The printer will center the page image on the selected media. Compatible with -dRotatePages=true, which may rotate the image on the media if it fits better, and then center it. Default value : false. Must be false if -dSetPageSize=true or -dFitPages=true.
The printer will try to set page size from the job. Only use with printers which can handle random PageSize. Defaults to true, must be false if -dRotatePages=true, -dCenterPages=true or -dFitPages=true.
The PostScript emitted by ps2write will try to use copypage to create the number of copies originally requested. Note that this relies on the level 2 semantics for copypage and will not reliably work on language level 3 devices (such as Ghostscript itself). Defaults to false. This flag is not compatible with the ProduceDSC flag which will take precedence if set.

These correspond to keys in the Postscript userdict of the target printer's virtual memory to control its behavior while executing a job generated with ps2ps2.

These keys can be set when executing ps2ps2 (or using the ps2write device), this 'fixes' the resulting behaviour according to which key has been set. If these keys are not defined during conversion, the resulting PostScript will not attempt any form of media selection. In this case the behaviour can then be modified by setting the keys, either by modifying the resulting PostScript or setting the values in some other manner on the target device.

See also the distiller params PSDocOptions and PSPageOptions mentioned above.


ps2ps2 provides a simplified interface to the Ghostscript command line. It is not possible to use -c option or pass multiple source files. For unrestricted access to the command line parameters, use Ghostscript directly. E.g. :

gs -q -dSAFER -dNOPAUSE -dBATCH [more options] \
source1.pdf [more files]

Copyright © 2000-2006 Artifex Software, Inc. All rights reserved.

This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.

Ghostscript version 9.16, 30 March 2015