How to use Ghostscript

Table of contents

For other information, see the Ghostscript overview, the new user's documentation on previewers and, if necessary, how to install Ghostscript.


Invoking Ghostscript

The command line to invoke Ghostscript is essentially the same on all systems, although the name of the executable program itself may differ among systems. For instance, to invoke Ghostscript on Unix:

gs [switches] {filename 1} ... [switches] {filename N} ...

Ghostscript's name on different systems
System    Ghostscript's name

Unix  gs
VMS  gs
DOS & MS Windows 3  gs386
MS Windows 95  gswin32
MS Windows 95 command line  gswin32c
OS/2  gsos2

Note, though, that on a system with a windowed graphical user interface, it's common to use Ghostscript through a previewer, so you should read the section about previewers in the documentation for new users.

Ghostscript is capable of interpreting PostScript, encapsulated PostScript (EPS), DOS EPS (EPSF), and -- if the executable was built for it -- Adobe Portable Document Format (PDF). The interpreter reads and executes the files in sequence, using the method described under "File searching" to find them. After doing this, it reads further lines of PostScript language commands from the primary input stream, normally the keyboard, interpreting each line separately. To quit the interpreter, type "quit". The interpreter also quits gracefully if it encounters end-of-file or control-C.

The interpreter recognizes many switches. A switch may appear anywhere in the command line, and applies to all files named after it on the line. Many of the switches include "=" followed by a parameter. (However, with the DOS executable gs386.exe in the standard Ghostscript distribution, you must use "#" rather than "=", because of a strange design decision in the Watcom C/C++ run-time library used to build it.)

Help at the command line: gs -h

You can get a brief help message by invoking Ghostscript with the -h or -? switch, like this:

gs -h
gs -?

(Of course, for "gs" use the right command for your system.) The message shows for this executable

Input from a pipe

As noted above, one normally specifies input with file names on the command line. However, one can also "pipe" input into Ghostscript by using the special file name "-", for instance

{some program producing PS} | gs {...options...} -

"-" differs from a named file in two respects:

  1. When Ghostscript finishes reading from the pipe, it quits rather than going into interactive mode. Because of this, "-" is really only useful as the last argument on the command line.
  2. "-" can't be used to pipe PDF input to Ghostscript. See "Using Ghostscript with PDF files" below.

Selecting an output device

Ghostscript may be built to handle multiple output devices, and it normally opens and directs output to the first one built in. Ghostscript's gs -h help message lists the output devices known to the executable. Once you invoke Ghostscript you can also find out what devices are available by "devicenames ==" at its command prompt.

A little more information about devices appears near the beginning of the files devs.mak (for Aladdin's own drivers) and contrib.mak (for user-contributed drivers) used to build Ghostscript. (If you got Ghostscript under the Aladdin Free Public License, the person or place from which you got it is also required to make the source code available to you; if you got it under the GNU General Public License (GPL), see the GNU General Public License for more information.)

To use device xyz as the initial output device, use the command-line switch

-sDEVICE=xyz

Note that this switch must precede the name of the first input file, and only its first use has any effect. For example, for printer output in a configuration that includes an Epson printer driver, instead of just "gs myfile.ps" you might use

gs -sDEVICE=epson myfile.ps

Alternatively, once you invoke Ghostscript and have its own command prompt you can type

(epson) selectdevice
(myfile.ps) run

All output then goes to the Epson printer instead of the display until you do something to change devices. You can switch devices at any time by using the selectdevice procedure, for instance like one of these:

(vga) selectdevice
(epson) selectdevice

A third possibility is to define an environment variable GS_DEVICE with the name of your desired default device. The order of precedence for these alternatives, highest to lowest, is:

selectdevice        Highest precedence
(command line)    
GS_DEVICE    
(first device built in)   Default; lowest precedence

Printer resolution

Some printers can print at several different resolutions, letting you balance resolution against printing speed. To select the resolution on such a printer, use the -r switch:

gs -sDEVICE=printer -rXRESxYRES

For example, on Epson-compatible printers you have these choices:

gs -sDEVICE=epson    -r60x72    9-pin    lowest resolution    fastest
    -r240x72       highest   slowest
 
    -r60x60   24-pin   lowest   fastest
    -r360x180       highest   slowest

Output to files

If you select a printer as the output device, Ghostscript also allows you to control where the device sends its output. On DOS systems, output normally goes directly to the printer (PRN); on Unix or VMS systems normally to a temporary file for later printing. To send the output to a file, use the -sOutputFile= switch (for compatibility with older versions of Ghostscript, -sOUTPUTFILE= also works). For instance, to direct all output into the file ABC.xyz, use

gs -sOutputFile=ABC.xyz

One page per file

You can also tell Ghostscript to put each page of output in a separate file. To send output to a series of files each representing a single page, use in the filename the printf format specifier "%d" (or its extended form like "%02d"); for instance


"%{n}d" in -sOutputFile=
Output specification     Produces the series of 1-page files

-sOutputFile=ABC%d.xyz   ABC1.xyz ... ABC10.xyz ...
-sOutputFile=ABC%03d.xyz   ABC001.xyz ... ABC010.xyz ...

Output to a pipe

On Unix systems you can use this switch to send output directly to a pipe. For example, to pipe the output to lpr, use the command

gs -sOutputFile=\|lpr

You can also send output to standard output for piping in the usual way supported by the system:

gs -sOutputFile=- -q | ...

(In this case you must also use the -q switch to prevent Ghostscript from writing messages to standard output which become mixed with the intended output stream.)

Output to graphics file formats

File formats like PCX and PBM are also "devices". When you select a file format as the "device", you must also specify an output file, for instance

gs -sDEVICE=pcxmono -sOutputFile=xyz.pcx

Here, as with printable files, you can use "%d" to specify one page per output file.

Choosing paper size

Ghostscript is distributed configured to use U.S. letter paper as its default page size, but it knows about many others, listed by name and size in the section on paper sizes known to Ghostscript. To select one of these as the default paper size for a single invocation of Ghostscript, you can use the -sPAPERSIZE= switch, for instance

-sPAPERSIZE=a4
-sPAPERSIZE=legal

Individual documents can (and often do) specify a paper size, which takes precedence over the default size. To force a specific paper size and ignore the paper size specified in the document, select a paper size as just described, and also include the -dFIXEDMEDIA switch on the command line.

Changing the installed default paper size

You can change the installed default paper size in installing Ghostscript or later, by editing the initialization file gs_init.ps. Find the consecutive lines

% Optionally choose a default paper size other than U.S. letter.
% (a4)

Then to make A4 the default paper size, uncomment the second line to change this to

% Optionally choose a default paper size other than U.S. letter.
(a4)

For a4 you can substitute any paper size Ghostscript knows.

How Ghostscript finds files

When looking for initialization files (gs_*.ps, pdf_*.ps), font files, the Fontmap file, and files named on the command line, Ghostscript first tests whether the file name specifies an explicit directory.


Testing a file name for an explicit directory
System    Does the name ...

Unix   Begin with /, ./ or ../ ?
DOS or MS Windows   Have : as its second character, or begin with /, \, ./, ../, .\, or ..\ ?
VMS   Contain a node, device, root, or directory specification?

If the test succeeds, the file name specifies an explicit directory and Ghostscript tries to open the file using the name given. Otherwise it tries directories in this order:

  1. The current directory (unless disabled by the -P- switch);
  2. The directories specified by -I switches in the command line, if any;
  3. The directories specified by the GS_LIB environment variable, if any;
  4. The directories specified by the GS_LIB_DEFAULT macro (if any) in the makefile when this executable was built.

GS_LIB_DEFAULT, GS_LIB, and the -I parameter may specify either a single directory or a list of directories separated by a character appropriate for the operating system (":" on Unix systems, "," on VMS systems, and ";" on DOS systems). We think that trying the current directory first is a very bad idea -- it opens serious security loopholes and can lead to very confusing errors if one has more than one version of Ghostscript in one's environment -- but when we attempted to change it, users insisted that we change it back. You can disable looking in the current directory first by using the -P- switch.

Note that Ghostscript does not use this file searching algorithm for the run or file operators: for these operators, it simply opens the file with the name given. To run a file using the searching algorithm, use runlibfile instead of run.

Finding PostScript Level 2 resources

Ghostscript uses a completely different rule for looking for files containing PostScript Level 2 "resources": per the Adobe documentation, it concatenates together

  1. the value of the system parameter GenericResourceDir (initially /Resource/)
  2. the name of the resource category (for instance, ProcSet)
  3. the value of the system parameter GenericResourcePathSep (initially "/")
  4. the name of the resource instance (for instance, CIDInit)

To look up fonts, after exhausting the search method described in the next section, it concatenates together

  1. the value of the system parameter FontResourceDir (initially /Resource/Font/)
  2. the name of the resource font (for instance, Times-Roman)

Note that even though the system parameters are named "somethingDir", they are not just plain directory names: they have "/" on the end, so that they can be concatenated with the category name or font name.

Font lookup

Ghostscript has a slightly different way to find the file containing a font with a given name. This rule uses not only the search path defined by -I, GS_LIB, and GS_LIB_DEFAULT as described above, but also an additional list of directories which is the value of the GS_FONTPATH environment variable (or the value provided with the -sFONTPATH= switch, if present).

When Ghostscript needs to find a font that isn't already loaded into memory, it begins by looking for Fontmap files in every directory on the search path: these files are catalogs of fonts and the files that contain them. (See the documentation of fonts for details.) If it can't find a font in any Fontmap file in the search path (or in the list provided with the -sFONTMAP= switch, if present), it looks at the GS_FONTPATH environment variable (or the value provided with the -sFONTPATH= switch, if present), which is also a list of directories. It goes to those directories one by one looking for all files that appear to contain PostScript fonts; it then effectively adds all those files and fonts to its internal copy of the Fontmap.


Differences between search path and font path
Search path     Font path

-I switch   -sFONTPATH= switch
 
GS_LIB and GS_LIB_DEFAULT environment variables   -sFONTPATH= and the GS_FONTPATH environment variable
 
Consulted first   Consulted only if search path doesn't provide the file.
 
Font-name-to-file-name mapping given in Fontmap files; aliases are possible, and there need not be any relation between the font name in the Fontmap and the FontName in the file.   Font-name-to-file-name mapping is implicit -- the FontName in the file is used. Aliases are not possible.
 
Only fonts and files named in Fontmap are used.   Every Type 1 font file in each directory is available; if TrueType fonts are supported (the ttfont.dev feature was included when the executable was built), they are also available.

If you are using one of the following types of computer, you may wish to set the environment variable GS_FONTPATH to the value indicated so that Ghostscript will automatically acquire all the installed Type 1 (and, if supported, TrueType) fonts (but see below for notes on systems marked with "*"):


Suggested GS_FONTPATH for different systems
     System type    GS_FONTPATH

    Digital Unix   /usr/lib/X11/fonts/Type1Adobe
    Ultrix   /usr/lib/DPS/outline/decwin
    HP-UX 9   /usr/lib/X11/fonts/type1.st/typefaces
    IBM AIX   /usr/lpp/DPS/fonts/outlines
/usr/lpp/X11/lib/X11/fonts/Type1
/usr/lpp/X11/lib/X11/fonts/Type1/DPS
    NeXT   /NextLibrary/Fonts/outline
    SGI IRIX   /usr/lib/DPS/outline/base
/usr/lib/X11/fonts/Type1
    SunOS 4.x
(NeWSprint only)
  newsprint_2.5/SUNWsteNP/reloc/$BASEDIR/NeWSprint/
    small_openwin/lib/fonts
*   SunOS 4.x   /usr/openwin/lib/X11/fonts/Type1/outline
*   Solaris 2.x   /usr/openwin/lib/X11/fonts/Type1/outline
    VMS   SYS$COMMON:[SYSFONT.XDPS.OUTLINE]

* On Solaris systems simply setting GS_FONTPATH may not work, because for some reason some versions of Ghostscript can't seem to find any of the Type1 fonts in /usr/openwin/lib/X11/fonts/Type1/outline. (It says: "15 files, 15 scanned, 0 new fonts".) See Fontmap.Sol instead. Also, on Solaris 2.x it's probably not worth your while to add Sun's fonts to your font path and Fontmap. The fonts Sun distributes on Solaris 2.x in the directories
/usr/openwin/lib/X11/fonts/Type1
/usr/openwin/lib/X11/fonts/Type1/outline

are already represented among the ones distributed as part of Ghostscript; and on some test files, Sun's fonts have been shown to cause incorrect displays with Ghostscript.

These paths may not be exactly right for your installation; if the indicated directory doesn't contain files whose names are familiar font names like Courier and Helvetica, you may wish to ask your system administrator where to find these fonts.

Adobe Acrobat comes with a set of fourteen Type 1 fonts, on Unix typically in a directory called .../Acrobat3/Fonts. There is no particular reason to use these instead of the corresponding professional fonts in the Ghostscript distribution, except to save about a megabyte of disk space, but the installation documentation explains how to do it on Unix and on DOS (where you can also use Adobe Type Manager fonts).

Temporary files


Where Ghostscript puts temporary files
Platform     Filename     Location

DOS and OpenVMS   _temp_XX.XXX   Current directory
OS/2   gsXXXXXX   Current directory
Unix   gs_XXXXX   /tmp

You can change in which directory Ghostscript creates temporary files by setting the TEMP environment variable to the name of the directory you want used. Ghostscript currently doesn't do a very good job of deleting temporary files when it exits; you may have to delete them manually from time to time.

Summary of environment variables

GS_DEVICE
Defines the default output device.
GS_FONTPATH
Specifies a list of directories to scan for fonts if a font requested can't be found anywhere on the search path.
GS_LIB
Provides a search path for initialization files and fonts.
GS_OPTIONS
Defines a list of command-line arguments to be processed before the ones actually specified on the command line. For example, setting GS_DEVICE to XYZ is equivalent to setting GS_OPTIONS to -sDEVICE=XYZ. The contents of GS_OPTIONS are not limited to switches; they may include actual file names or even "@file" arguments.
TEMP
Defines a directory name for temporary files.

Using Ghostscript with PDF files

Ghostscript is normally built (except on 16-bit DOS platforms) to interpret both PostScript and PDF files, examining each file to determine automatically whether its contents are PDF or PostScript. All the normal switches and procedures for interpreting PostScript files also apply to PDF files, with a few exceptions. In addition, the pdf2ps utility uses Ghostscript to convert PDF to (Level 2) PostScript.

PDF files from standard input

Using the "-" switch you can provide PDF input from a file, but not from a pipe, because the PDF language, unlike the PostScript language, inherently requires random access to the file, while a pipe is always sequential. That is,

gs - <somefile.pdf        (is permissible)
{some program producing PDF} | gs -   (is not permissible)

Switches for PDF files

-dFirstPage=pagenumber
Begins interpreting on the designated page of the document.
-dLastPage=pagenumber
Stops interpreting after the designated page of the document.
-sPSFile=filename
Writes the PostScript equivalent of the PDF input into the given file.

Notes on specific platforms

Unix

The Ghostscript distribution includes some Unix shell scripts to use with Ghostscript in different environments. These are all user-contributed code, so if you have questions, please contact the user identified in the file, not Aladdin Enterprises.

pv.sh
Preview a specified page of a dvi file in an X window
sysvlp.sh
System V 3.2 lp interface for parallel printer
pj-gs.sh
Printing on an H-P PaintJet under HP-UX
unix-lpr.sh
Queue filter for lpr under Unix; its documentation is intended for system administrators
lprsetup.sh
Setup for unix-lpr.sh

VMS

Using X Windows on VMS

If you are using on an X Windows display, you can set it up with the node name and network transport, for instance

$ set display/create/node="doof.city.com"/transport=tcpip

and then run Ghostscript by typing gs at the command line.


DOS


X Windows

Ghostscript looks for the following resources under the program name ghostscript and class name Ghostscript; the ones marked "**" are calculated from display metrics:


X Windows resources
Name    Class    Default

background   Background   white
foreground   Foreground   black
borderColor   BorderColor   black
borderWidth   BorderWidth   1
geometry   Geometry   NULL
xResolution   Resolution   **
yResolution   Resolution   **
useExternalFonts   UseExternalFonts   true
useScalableFonts   UseScalableFonts   true
logExternalFonts   LogExternalFonts   false
externalFontTolerance   ExternalFontTolerance   10.0
palette   Palette   Color
maxGrayRamp   MaxGrayRamp   128
maxRGBRamp   MaxRGBRamp   5
maxDynamicColors   MaxDynamicColors   256
useBackingPixmap   UseBackingPixmap   true
useXPutImage   UseXPutImage   true
useXSetTile   UseXSetTile   true
regularFonts   RegularFonts   See "X fonts"
symbolFonts   SymbolFonts   See "X fonts"
dingbatFonts   DingbatFonts   See "X fonts"

X resources

Working around bugs in X servers

The "use..." resources exist primarily to work around bugs in X servers.

X fonts

To use native X11 fonts, Ghostscript must map PostScript font names to the XLFD font names. The resources regularFonts (fonts available in standard or ISO-Latin-1 encoding), symbolFonts (using Symbol encoding), and dingbatFonts (using Dingbat encoding) give the name mapping for different encodings. The XLFD font name in the mapping must contain 7 dashes; the X driver adds the additional size and encoding fields to bring the total number of dashes in the font name to 14. See the appendix "X default font mappings" for the full list of default mappings.

Users who switch regularly between different X servers may wish to use the "*" wild card in place of the foundry name (itc, monotype, linotype, b&h, or adobe); users who do not switch X servers should leave the explicit foundry in the name, since it speeds up access to fonts.

Ghostscript takes advantage of the "HP XLFD Enhancements," if available, to use native X11 fonts for fonts that are anamorphically scaled, rotated, or mirrored. If the changes have been installed to the X or font server, they are automatically used when appropriate.


SCO Unix

Because of bugs in the SCO Unix kernel, Ghostscript will not work if you select direct screen output and also allow it to write messages on the console. If you are using direct screen output, redirect Ghostscript's terminal output to a file.


Switches

Unless otherwise noted, these switches can be used on all platforms.

Normal switches

Input control

@filename
Causes Ghostscript to read filename and treat its contents the same as the command line. (This is intended primarily for getting around DOS's 128-character limit on the length of a command line.) Switches or file names in the file may be separated by any amount of white space (space, tab, line break); there is no limit on the size of the file.
-- filename arg1 ...
-+ filename arg1 ...
Takes the next argument as a file name as usual, but takes all remaining arguments (even if they have the syntactic form of switches) and defines the name ARGUMENTS in userdict (not systemdict) as an array of those strings, before running the file. When Ghostscript finishes executing the file, it exits back to the shell.
-@ filename arg1 ...
Does the same thing as -- and -+, but expands @filename arguments.
-c tokens ...
Interprets arguments as PostScript code up to the next argument that begins with "-" followed by a non-digit, or with "@". For example, if the file quit.ps contains just the word "quit", then -c quit on the command line is equivalent to quit.ps there. Each argument must be exactly one token, as defined by the token operator.
-f
Interprets following non-switch arguments as file names to be executed using the normal run command. Since this is the default behavior, -f is useful only for terminating the list of tokens for the -c switch.
-ffilename
Execute the given file, even if its name begins with a "-" or "@".

File searching

Note that by "library files" here we mean all the files identified using the search rule under "How Ghostscript finds files" above: Ghostscript's own initialization files, fonts, and files named on the command line.

-Idirectories
Adds the designated list of directories at the head of the search path for library files.
-P
Makes Ghostscript look first in the current directory for library files. This is currently the default.
-P-
Makes Ghostscript not look first in the current directory for library files (unless, of course, the first explicitly supplied directory is ".").

Setting parameters

-Dname
-dname
Define a name in systemdict with value=true.
-Dname=token
-dname=token
Define a name in systemdict with the given definition. The token must be exactly one token (as defined by the token operator) and must not contain any whitespace. If the token is a non-literal name, it must be true, false, or null.
-Sname=string
-sname=string
Define a name in systemdict with a given string as value. This is different from -d. For example, -dXYZ=35 on the command line is equivalent to the program fragment
/XYZ 35 def

whereas -sXYZ=35 is equivalent to

/XYZ (35) def
-uname
Un-define a name, cancelling -d or -s.

Note that the initialization file gs_init.ps makes systemdict read-only, so the values of names defined with -D, -d, -S, and -s cannot be changed -- although, of course, they can be superseded by definitions in userdict or other dictionaries.

-gnumber1xnumber2
Equivalent to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2, specifying the device width and height in pixels for the benefit of devices such as X11 windows and VESA displays that require (or allow) you to specify width and height. Note that this causes documents of other sizes to be clipped, not scaled: see -dFIXEDMEDIA below.
-rnumber (same as -rnumberxnumber)
-rnumber1xnumber2
Equivalent to -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLUTION=number2, specifying the device horizontal and vertical resolution in pixels per inch for the benefit of devices such as printers that support multiple X and Y resolutions.

Suppress messages

-q
Quiet startup: suppress normal startup messages, and also do the equivalent of -dQUIET.

Special names (with -d and -s)

-dBATCH
Causes Ghostscript to exit after processing all files named on the command line, rather than going into an interactive loop reading PostScript commands. Equivalent to putting -c quit at the end of the command line.
-dCOLORSCREEN
-dCOLORSCREEN=0
-dCOLORSCREEN=false
On high-resolution devices (at least 150 dpi resolution, or -dDITHERPPI specified), -dCOLORSCREEN forces the use of separate halftone screens with different angles for CMYK or RGB if halftones are needed (this produces the best-quality output); -dCOLORSCREEN=0 uses separate screens with the same frequency and angle; -dCOLORSCREEN=false forces the use of a single binary screen. The default if COLORSCREEN is not specified is to use separate screens with different angles if the device has fewer than 5 bits per color, and a single binary screen (which is never actually used under normal circumstances) on all other devices.
-dDELAYBIND
Causes bind to remember all its invocations, but not actually execute them until the .bindnow procedure is called. Useful only for certain specialized packages like pstotext that redefine operators.
-dDISKFONTS
Causes individual character outlines to be loaded from the disk the first time they are encountered. (Normally Ghostscript loads all the character outlines when it loads a font.) This may allow loading more fonts into memory at the expense of slower rendering. DISKFONTS is effective only if the diskfont feature was built into the executable; otherwise it is ignored.
-dDITHERPPI=lpi
Forces all devices to be considered high-resolution, and forces use of a halftone screen or screens with lpi lines per inch, disregarding the actual device resolution. Reasonable values for lpi are N/5 to N/20, where N is the resolution in dots per inch.
-dFIXEDMEDIA
Causes the media size to be fixed after initialization, forcing pages of other sizes or orientations to be clipped. This may be useful when printing documents on a printer that can handle their requested paper size but whose default is some other size. Note that -g automatically sets -dFIXEDMEDIA, but -sPAPERSIZE= does not.
-dFIXEDRESOLUTION
Causes the media resolution to be fixed similarly. -r automatically sets -dFIXEDRESOLUTION.
-dLOCALFONTS
Causes Type 1 fonts to be loaded into the current VM -- normally local VM -- instead of always being loaded into global VM. Useful only for compatibility with Adobe printers for loading some obsolete fonts.
-dNOBIND
Disables the bind operator. Useful only for debugging.
-dNOCACHE
Disables character caching. Useful only for debugging.
-dNOCIE
Substitutes DeviceGray and DeviceRGB for CIEBasedA and CIEBasedABC color spaces respectively. Useful only on very slow systems where color accuracy is less important.
-dNODISPLAY
Initializes Ghostscript with a null device (a device that discards the output image) rather than the default device or the device selected with -sDEVICE=. This is usually useful only when running PostScript code whose purpose is to compute something rather than to produce an output image; for instance, when converting PostScript to PDF.
-dNOFONTMAP
Suppresses the normal loading of the Fontmap file. This may be useful in environments without a file system.
-dNOFONTPATH
Suppresses consultation of GS_FONTPATH. This may be useful for debugging.
-dNOGC
Suppresses the initial automatic enabling of the garbage collector in Level 2 systems. (The vmreclaim operator is not disabled.) Useful only for debugging.
-dNOINTERPOLATE
Turns off image interpolation, improving performance on interpolated images at the expense of image quality.
-dNOPAGEPROMPT
Disables only the prompt, but not the pause, at the end of each page. This may be useful on PC displays that get confused if a program attempts to write text to the console while the display is in a graphics mode.
-dNOPAUSE
Disables the prompt and pause at the end of each page. Normally one should use this (along with -dBATCH) when producing output on a printer or to a file; it also may be desirable for applications where another program is "driving" Ghostscript.
-dNOPLATFONTS
Disables the use of fonts supplied by the underlying platform (X Windows or Microsoft Windows). This may be needed if the platform fonts look undesirably different from the scalable fonts.
-dNOPROMPT
Disables the prompt printed by Ghostscript when it expects interactive input, as well as the end-of-page prompt (-dNOPAGEPROMPT); also disables the implicit flushpage that normally occurs each time Ghostscript asks for more input. This allows piping input directly into Ghostscript, as long as the data doesn't refer to currentfile.
-dORIENT1=true
-dORIENT1=false
Defines the meaning of the 0 and 1 orientation values for the setpage[params] compatibility operators. The default value of ORIENT1 is true (set in gs_init.ps), which is the correct value for most files that use setpage[params] at all, namely, files produced by badly designed applications that "know" that the output will be printed on certain roll-media printers: these applications use 0 to mean landscape and 1 to mean portrait. -dORIENT1=false declares that 0 means portrait and 1 means landscape, which is the convention used by a smaller number of files produced by properly written applications.
-dQUIET
Suppresses routine information comments on standard output. This is currently necessary when redirecting device output to standard output.
-dSAFER
Disables the deletefile and renamefile operators, and the ability to open files in any mode other than read-only. This may be desirable for spoolers or other sensitive environments.
-dSHORTERRORS
Makes certain error and information messages more Adobe-compatible.
-dSTRICT
Disables as many Ghostscript extensions as feasible, to be more helpful in debugging applications that produce output for Adobe and other RIPs.
-dWRITESYSTEMDICT
Leaves systemdict writable. This is necessary when running special utility programs such as font2c and pcharstr, which must bypass normal PostScript access protection.
-sDEVICE=device
Selects an alternate initial output device.
-sFONTMAP=filename1;filename2;...
Specifies alternate name or names for the Fontmap file. Note that the names are separated by ":" on Unix systems, by ";" on DOS or MS Windows systems, and by "," on VMS systems, just as for search paths.
-sFONTPATH=dir1;dir2;...
Specifies a list of directories that will be scanned when looking for fonts not found on the search path, overriding the environment variable GS_FONTPATH.
-sOutputFile=filename
Selects an alternate output file (or pipe) for the initial output device, as described above.
-sSUBSTFONT=fontname
Causes the given font to be substituted for all unknown fonts, instead of using the normal intelligent substitution algorithm. Also, in this case, the font returned by findfont is the actual font named "fontname", not a copy of the font with the FontName changed to the requested one.

Debugging

The information here describing the debugging switches is probably interesting only to developers. The -Z switch applies only if the interpreter was built for a debugging configuration. In the table below, the first column is a debugging switch, the second is an equivalent switch (if any) and the third is its usage.

Switches used in debugging
Switch    Equivalent     

-A   -Z@   Fill empty storage with a distinctive bit pattern for debugging
-A-   -Z-@   Turn off -A
-Bsize       Run all subsequent files named on the command line (except for -F) through the run_string interface, using a buffer of size bytes
-B-       Turn off -B: run subsequent files (except for -F) directly in the normal way
-E   -Z#   Turn on tracing of error returns from operators
-E-   -Z-#   Turn off -E
-Ffile       Execute the file with -B1 temporarily in effect
-Mn       Force the interpreter's allocator to acquire additional memory in units of nK bytes, rather than the default (currently 20K on DOS systems, 50K on Unix). n is a positive decimal integer, on DOS systems no greater than 63.
-Nn       Allocate space for nK names, rather than the default (normally 64K). n may be greater than 64 only if EXTEND_NAMES was defined when the interpreter was compiled .
-Zxxx
-Z-xxx
      Turn debugging printout on (off). Each of the xxx characters selects an option. Case is significant: "a" and "A" have different meanings.
0
garbage collector, minimal detail
1
type 1 and type 42 font interpreter
2
curve subdivider/rasterizer
   3
curve subdivider/rasterizer, detail
4
garbage collector (strings)
   5
garbage collector (strings, detail)
6
garbage collector (chunks, roots)
   7
garbage collector (objects)
   8
garbage collector (refs)
   9
garbage collector (pointers)
a
allocator (large blocks only)
   A
allocator (all calls)
b
bitmap image processor
   B
bitmap images, detail
c
color/halftone mapper
d
dictionary put/undef
   D
dictionary lookups
e
external (OS-related) calls
f
fill algorithm (summary)
   F
fill algorithm (detail)
g
gsave/grestore[all]
h
halftone renderer
   H
halftones, every pixel
i
interpreter, just names
   I
interpreter, everything
j
(Japanese) composite fonts
k
character cache and xfonts
   K
character cache, every access
l
command lists, bands
   L
command lists, everything
m
makefont and font cache
n
name lookup (new names only)
o
outliner (stroke)
   O
stroke detail
p
band list paths
   P
all paths
q
clipping
r
arc renderer
s
streams
   S
scanner
t
tiling algorithm
u
undo saver (for save/restore), finalization
   U
undo saver, more detail
v
rectangle fill
   V
device-level output
w
compression encoder/decoder
x
transformations
y
Type 1 hints
   Y
Type 1 hints, every access
z
trapezoid fill
#
operator error returns
%
externally processed comments
*
image and RasterOp parameters
:
command list and allocator/time summary
~
math functions
'
contexts, create/destroy
   "
contexts, every operation
|
(reserved for experimental code)

The following switch affects what is printed, but does not select specific items for printing:

/
include file name and line number on all trace output

These switches select debugging options other than what should be printed:

$
set unused parts of object references to identifiable garbage values
+
use minimum-size stack blocks
,
don't use path-based banding
.
use small-memory table sizes even on large-memory machines
?
validate pointers before, during and after garbage collection, also before and after save and restore; also make other allocator validity checks
@
fill newly allocated, garbage-collected, and freed storage with a marker (a1, c1, and f1 respectively)


Appendix: Paper sizes known to Ghostscript

The paper sizes known to Ghostscript are defined at the beginning of the initialization file gs_statd.ps; see the comments there for more details about the definitions. The table here lists them by name and size. gs_statd.ps defines their sizes exactly in points, and the dimensions in inches (at 72 points per inch) and centimeters shown in the table are derived from those, rounded to the nearest 0.1 unit. A guide to international paper sizes can be found at

http://www.twics.com/~eds/papersize.html

Paper sizes known to Ghostscript
U.S. standard
         Inches        cm        Points         
Name    W  ×  H     W  ×  H     W  ×  H     

11x17   11.0  17.0  27.9  43.2  792  1224  11×17in portrait
ledger  17.0 11.0 43.2 27.9 1224 792 11×17in landscape
legal  8.5 14.0 21.6 35.6 612 1008  
letter  8.5 11.0 21.6 27.9 612 792  
lettersmall  8.5 11.0 21.6 27.9 612 792  
archE  36.0 48.0 91.4 121.9 2592 3456  
archD  24.0 36.0 61.0 91.4 1728 2592  
archC  18.0 24.0 45.7 61.0 1296 1728  
archB  12.0 18.0 30.5 45.7 864 1296  
archA  9.0 12.0 22.9 30.5 648 864  

ISO standard

a0  33.1 46.8 84.0 118.8 2380 3368  
a1  23.4 33.1 59.4 84.0 1684 2380  
a2  16.5 23.4 42.0 59.4 1190 1684  
a3  11.7 16.5 29.7 42.0 842 1190  
a4  8.3 11.7 21.0 29.7 595 842  
a4small  8.3 11.7 21.0 29.7 595 842  
a5  5.8 8.3 14.9 21.0 421 595  
a6  4.1 5.8 10.5 14.9 297 421  
a7  2.9 4.1 7.4 10.5 210 297  
a8  2.1 2.9 5.2 7.4 148 210  
a9  1.5 2.1 3.7 5.2 105 148  
a10  1.0 1.5 2.6 3.7 74 105  
b0  39.4 55.7 100.0 141.4 2836 4008  
b1  27.8 39.4 70.7 100.0 2004 2836  
b2  19.7 27.8 50.0 70.7 1418 2004  
b3  13.9 19.7 35.3 50.0 1002 1418  
b4  9.8 13.9 25.0 35.3 709 1002  
b5  7.0 9.8 17.7 25.0 501 709  
c0  36.1 51.1 91.7 129.7 2600 3677  
c1  25.5 36.1 64.8 91.7 1837 2600  
c2  18.0 25.5 45.8 64.8 1298 1837  
c3  12.8 18.0 32.4 45.8 918 1298  
c4  9.0 12.8 22.9 32.4 649 918  
c5  6.4 9.0 16.2 22.9 459 649  
c6  4.5 6.4 11.4 16.2 323 459  

Other

flsa  8.5 13.0 21.6 33.0 612 936 U.S. foolscap
flse  8.5 13.0 21.6 33.0 612 936 European foolscap
halfletter  5.5 8.5 14.0 21.6 396 612  

Appendix: X default font mappings

Standard X servers

Regular fonts

    AvantGarde-Book:              -Adobe-ITC Avant Garde Gothic-Book-R-Normal--\n\
    AvantGarde-BookOblique:       -Adobe-ITC Avant Garde Gothic-Book-O-Normal--\n\
    AvantGarde-Demi:              -Adobe-ITC Avant Garde Gothic-Demi-R-Normal--\n\
    AvantGarde-DemiOblique:       -Adobe-ITC Avant Garde Gothic-Demi-O-Normal--\n\
    Bookman-Demi:                 -Adobe-ITC Bookman-Demi-R-Normal--\n\
    Bookman-DemiItalic:           -Adobe-ITC Bookman-Demi-I-Normal--\n\
    Bookman-Light:                -Adobe-ITC Bookman-Light-R-Normal--\n\
    Bookman-LightItalic:          -Adobe-ITC Bookman-Light-I-Normal--\n\
    Courier:                      -Adobe-Courier-Medium-R-Normal--\n\
    Courier-Bold:                 -Adobe-Courier-Bold-R-Normal--\n\
    Courier-BoldOblique:          -Adobe-Courier-Bold-O-Normal--\n\
    Courier-Oblique:              -Adobe-Courier-Medium-O-Normal--\n\
    Helvetica:                    -Adobe-Helvetica-Medium-R-Normal--\n\
    Helvetica-Bold:               -Adobe-Helvetica-Bold-R-Normal--\n\
    Helvetica-BoldOblique:        -Adobe-Helvetica-Bold-O-Normal--\n\
    Helvetica-Narrow:             -Adobe-Helvetica-Medium-R-Narrow--\n\
    Helvetica-Narrow-Bold:        -Adobe-Helvetica-Bold-R-Narrow--\n\
    Helvetica-Narrow-BoldOblique: -Adobe-Helvetica-Bold-O-Narrow--\n\
    Helvetica-Narrow-Oblique:     -Adobe-Helvetica-Medium-O-Narrow--\n\
    Helvetica-Oblique:            -Adobe-Helvetica-Medium-O-Normal--\n\
    NewCenturySchlbk-Bold:        -Adobe-New Century Schoolbook-Bold-R-Normal--\n\
    NewCenturySchlbk-BoldItalic:  -Adobe-New Century Schoolbook-Bold-I-Normal--\n\
    NewCenturySchlbk-Italic:      -Adobe-New Century Schoolbook-Medium-I-Normal--\n\
    NewCenturySchlbk-Roman:       -Adobe-New Century Schoolbook-Medium-R-Normal--\n\
    Palatino-Bold:                -Adobe-Palatino-Bold-R-Normal--\n\
    Palatino-BoldItalic:          -Adobe-Palatino-Bold-I-Normal--\n\
    Palatino-Italic:              -Adobe-Palatino-Medium-I-Normal--\n\
    Palatino-Roman:               -Adobe-Palatino-Medium-R-Normal--\n\
    Times-Bold:                   -Adobe-Times-Bold-R-Normal--\n\
    Times-BoldItalic:             -Adobe-Times-Bold-I-Normal--\n\
    Times-Italic:                 -Adobe-Times-Medium-I-Normal--\n\
    Times-Roman:                  -Adobe-Times-Medium-R-Normal--\n\
    ZapfChancery-MediumItalic:    -Adobe-ITC Zapf Chancery-Medium-I-Normal--

Symbol fonts

    Symbol:                       -Adobe-Symbol-Medium-R-Normal--

Dingbat fonts

    ZapfDingbats:                 -Adobe-ITC Zapf Dingbats-Medium-R-Normal--

Sun OpenWindows

For Sun's X11/NeWS one can use the OpenWindows scalable fonts instead, which gives good output for any point size. In this environment, the relevant section of the resource file should look like this:

Ghostscript.regularFonts: \
    AvantGarde-Book:              -itc-avantgarde-book-r-normal-- \n\
    AvantGarde-BookOblique:       -itc-avantgarde-book-o-normal-- \n\
    AvantGarde-Demi:              -itc-avantgarde-demi-r-normal-- \n\
    AvantGarde-DemiOblique:       -itc-avantgarde-demi-o-normal-- \n\
    Bembo:                        -monotype-bembo-medium-r-normal-- \n\
    Bembo-Bold:                   -monotype-bembo-bold-r-normal-- \n\
    Bembo-BoldItalic:             -monotype-bembo-bold-i-normal-- \n\
    Bembo-Italic:                 -monotype-bembo-medium-i-normal-- \n\
    Bookman-Demi:                 -itc-bookman-demi-r-normal-- \n\
    Bookman-DemiItalic:           -itc-bookman-demi-i-normal-- \n\
    Bookman-Light:                -itc-bookman-light-r-normal-- \n\
    Bookman-LightItalic:          -itc-bookman-light-i-normal-- \n\
    Courier:                      -itc-courier-medium-r-normal-- \n\
    Courier-Bold:                 -itc-courier-bold-r-normal-- \n\
    Courier-BoldOblique:          -itc-courier-bold-o-normal-- \n\
    Courier-Oblique:              -itc-courier-medium-o-normal-- \n\
    GillSans:                     -monotype-gill-medium-r-normal-sans- \n\
    GillSans-Bold:                -monotype-gill-bold-r-normal-sans- \n\
    GillSans-BoldItalic:          -monotype-gill-bold-i-normal-sans- \n\
    GillSans-Italic:              -monotype-gill-normal-i-normal-sans- \n\
    Helvetica:                    -linotype-helvetica-medium-r-normal-- \n\
    Helvetica-Bold:               -linotype-helvetica-bold-r-normal-- \n\
    Helvetica-BoldOblique:        -linotype-helvetica-bold-o-normal-- \n\
    Helvetica-Narrow:             -linotype-helvetica-medium-r-narrow-- \n\
    Helvetica-Narrow-Bold:        -linotype-helvetica-bold-r-narrow-- \n\
    Helvetica-Narrow-BoldOblique: -linotype-helvetica-bold-o-narrow-- \n\
    Helvetica-Narrow-Oblique:     -linotype-helvetica-medium-o-narrow-- \n\
    Helvetica-Oblique:            -linotype-helvetica-medium-o-normal-- \n\
    LucidaBright:                 -b&h-lucidabright-medium-r-normal-- \n\
    LucidaBright-Demi:            -b&h-lucidabright-demibold-r-normal-- \n\
    LucidaBright-DemiItalic:      -b&h-lucidabright-demibold-i-normal-- \n\
    LucidaBright-Italic:          -b&h-lucidabright-medium-i-normal-- \n\
    LucidaSans:                   -b&h-lucida-medium-r-normal-sans- \n\
    LucidaSans-Bold:              -b&h-lucida-bold-r-normal-sans- \n\
    LucidaSans-BoldItalic:        -b&h-lucida-bold-i-normal-sans- \n\
    LucidaSans-Italic:            -b&h-lucida-medium-i-normal-sans- \n\
    LucidaSans-Typewriter:        -b&h-lucidatypewriter-medium-r-normal-sans- \n\
    LucidaSans-TypewriterBold:    -b&h-lucidatypewriter-bold-r-normal-sans- \n\
    NewCenturySchlbk-BoldItalic:  -linotype-new century schoolbook-bold-i-normal-- \n\
    NewCenturySchlbk-Bold:        -linotype-new century schoolbook-bold-r-normal-- \n\
    NewCenturySchlbk-Italic:      -linotype-new century schoolbook-medium-i-normal-- \n\
    NewCenturySchlbk-Roman:       -linotype-new century schoolbook-medium-r-normal-- \n\
    Palatino-Bold:                -linotype-palatino-bold-r-normal-- \n\
    Palatino-BoldItalic:          -linotype-palatino-bold-i-normal-- \n\
    Palatino-Italic:              -linotype-palatino-medium-i-normal-- \n\
    Palatino-Roman:               -linotype-palatino-medium-r-normal-- \n\
    Rockwell:                     -monotype-rockwell-medium-r-normal-- \n\
    Rockwell-Bold:                -monotype-rockwell-bold-r-normal-- \n\
    Rockwell-BoldItalic:          -monotype-rockwell-bold-i-normal-- \n\
    Rockwell-Italic:              -monotype-rockwell-medium-i-normal-- \n\
    Times-Bold:                   -linotype-times-bold-r-normal-- \n\
    Times-BoldItalic:             -linotype-times-bold-i-normal-- \n\
    Times-Italic:                 -linotype-times-medium-i-normal-- \n\
    Times-Roman:                  -linotype-times-medium-r-normal-- \n\
    Utopia-Bold:                  -adobe-utopia-bold-r-normal-- \n\
    Utopia-BoldItalic:            -adobe-utopia-bold-i-normal-- \n\
    Utopia-Italic:                -adobe-utopia-regular-i-normal-- \n\
    Utopia-Regular:               -adobe-utopia-regular-r-normal-- \n\
    ZapfChancery-MediumItalic:    -itc-zapfchancery-medium-i-normal-- \n
Ghostscript.dingbatFonts: \
    ZapfDingbats:                 -itc-zapfdingbats-medium-r-normal--
Ghostscript.symbolFonts: \
    Symbol:                       --symbol-medium-r-normal--

Copyright © 1996, 1997, 1998 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 5.50, 16 September 1998