Ghostscript is an implementation of Adobe Systems'
PostScript (tm) language, which is in turn similar to Forth.
in sequence and executes them as Ghostscript programs.
After doing this, it reads further input from the standard input stream
(normally the keyboard). Each line is interpreted separately.
To exit from the interpreter, enter the `quit' command.
The interpreter also exits gracefully if it encounters end-of-file.
Typing the interrupt character (e.g. Control-C) is also safe.
The interpreter recognizes several switches described below, which may appear
anywhere in the command line and apply to all files thereafter.
You can get a help message by invoking Ghostscript with the
option. This message also lists the available devices.
Ghostscript may be built with multiple output devices. Ghostscript
normally opens the first one and directs output to it. To use device xyz
as the initial output device, include the switch
in the command line. Note that this switch must precede the first .ps
file, and only its first invocation has any effect. For example, for
printer output in a normal configuration that includes an Epson printer
driver, you might use the shell command
gs -sDEVICE=epson myfile.ps
instead of just
Alternatively, you can type
All output then goes to the printer instead of the display until further
notice. You can switch devices at any time by using the selectdevice
As yet a third alternative, you can define an environment variable
GS_DEVICE as the desired default device name. The order of precedence for
these alternatives, highest to lowest, is:
(first device in build list)
To select the density on a printer, use
gs -sDEVICE=<device> -r<xres>x<yres>
For example, on a 9-pin Epson-compatible printer, you can get the
lowest-density (fastest) mode with
gs -sDEVICE=epson -r60x72
and the highest-density mode with
gs -sDEVICE=epson -r240x72.
If you select a printer as the output device, Ghostscript also allows you
to control where the device sends its output. Normally, output goes
directly to a scratch file on Unix systems.
To send the output to a series of files foo1.xyz,
foo2.xyz, ..., use the switch
The %d is a printf format specification; you can use
other formats like %02d. Each file will receive one page of output.
Alternatively, to send the output to a single file foo.xyz, with all
the pages concatenated, use the switch
On Unix systems, you can send the output directly to a pipe. For
example, to pipe the output to the command `lpr' (which, on many Unix
systems, is the command that spools output for a printer), use the
You can also send output to stdout for piping with the switch
In this case you must also use the -q switch, to prevent Ghostscript from
writing messages to stdout.
To find out what devices are available, type
after starting up Ghostscript.
Alternatively, you can use the -h or -? switch in the command line;
the help message also lists the available devices.
To select a different paper size, use the command line switch
As of this printing, the known paper sizes, defined in gs_statd.ps, are:
l l l l l.
PAPERSIZE>X">Y">X cm>Y cm
When looking for the initialization files (gs_*.ps), the files related
to fonts, or the file for the `run' operator, Ghostscript first tries
opening the file with the name as given (i.e., using the current
working directory if none is specified). If this fails, and the file
name doesn't specify an explicit directory or drive (i.e., doesn't
begin with `/' on Unix systems), Ghostscript will try directories in the
The directory/ies specified by the -I switch(es) in the command
line (see below), if any;
The directory/ies specified by the GS_LIB environment variable,
The directory/ies specified by the GS_LIB_DEFAULT macro in the
Ghostscript makefile (which has been set to
where 3.N is the Ghostscript version number).
Each of these (GS_LIB_DEFAULT, GS_LIB, and -I parameter) may be either
a single directory, or a list of directories separated by a `:'.
Ghostscript looks for the following resources under the program name
The border width in pixels (default = 1).
The name of the border color (default = black).
The window size and placement, WxH+X+Y (default is NULL).
The number of x pixels per inch (default is computed from WidthOfScreen
The number of y pixels per inch (default is computed from
HeightOfScreen and HeightMMOfScreen).
Determines whether backing store is to be used for saving display window
(default = true).
See the file `use.doc' for a more complete list of resources.
To set these resources, put them in a file (such as ~/.Xresources) in the
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,
running the file. When Ghostscript
finishes executing the file, it exits back to the shell.
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.
Define a name in systemdict with value=null.
Define a name in systemdict with a given string as value. This is
different from -d. For example, -dname=35 is equivalent to the
/name 35 def
-s name=35 is equivalent to
/name (35) def
Quiet startup - suppress normal startup messages, and also do the
equivalent of -dQUIET.
This is for the benefit of devices (such as X11 windows)
that require (or allow) width and height to be specified.
This is for the benefit of devices (such as printers)
that support multiple X and Y resolutions.
(If only one number is given, it is used for both X and Y resolutions.)
Adds the designated list of directories at the head of the
search path for library files.
This is not really a switch. It indicates to Ghostscript that the
standard input is coming from a file or a pipe. Ghostscript reads
from stdin until reaching end-of-file, executing it like any other
file, and then continues processing the command line. At the end of
the command line, Ghostscript exits rather than going into its
Note that gs_init.ps makes systemdict read-only, so the values of names
defined with -D/d/S/s cannot be changed (although, of course, they can be
superseded by definitions in userdict or other dictionaries.)
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 RAM, at the expense of slower rendering.
Disables character caching. Only useful for debugging.
Disables the `bind' operator. Only useful for debugging.
Suppresses the normal initialization of the output device.
This may be useful when debugging.
Disables the prompt and pause at the end of each page.
This may be desirable for applications where another program is
Disables the use of fonts supplied by the underlying platform
(e.g. X Windows). This may be needed if the platform
fonts look undesirably different from the scalable fonts.
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.
Leaves systemdict writable. This is necessary when running
special utility programs such as font2c and pcharstr, which must bypass
normal PostScript access protection.
Selects an alternate initial output device, as described above.
Selects an alternate output file (or pipe) for the initial output
device, as described above.
Startup-files, utilities, and basic font definitions.
Additional font definitions.
Demo Ghostscript files.
Assorted document files.
String of options to be processed before the command line options.
Used to define the device used.
Path names used to search for fonts
Path names for initialization files and fonts
Where temporary files are made
The various Ghostscript document files (above).
See the network news group `comp.lang.postscript'.