1GS(1)                             Ghostscript                            GS(1)
2
3
4

NAME

6       gs  -  Ghostscript  (PostScript  and  PDF language interpreter and pre‐
7       viewer)
8

SYNOPSIS

10       gs [ options ] [ files ] ... (Unix, VMS)
11       gswin32c [ options ] [ files ] ... (MS Windows)
12       gswin32 [ options ] [ files ] ... (MS Windows 3.1)
13       gsos2 [ options ] [ files ] ... (OS/2)
14

DESCRIPTION

16       The gs (gswin32c, gswin32, gsos2) command invokes Ghostscript,  an  in‐
17       terpreter of Adobe Systems' PostScript(tm) and Portable Document Format
18       (PDF) languages.  gs reads "files" in sequence  and  executes  them  as
19       Ghostscript programs. After doing this, it reads further input from the
20       standard input stream (normally the keyboard), interpreting  each  line
21       separately and output to an output device (may be a file or an X11 win‐
22       dow preview, see below). The interpreter exits gracefully when  it  en‐
23       counters the "quit" command (either in a file or from the keyboard), at
24       end-of-file, or at an interrupt signal (such as Control-C at  the  key‐
25       board).
26
27       The  interpreter recognizes many option switches, some of which are de‐
28       scribed below. Please see the usage documentation for complete informa‐
29       tion. Switches may appear anywhere in the command line and apply to all
30       files thereafter.  Invoking Ghostscript with the -h or -?  switch  pro‐
31       duces  a  message  which shows several useful switches, all the devices
32       known to that executable, and the search path for  fonts;  on  Unix  it
33       also shows the location of detailed documentation.
34
35       Ghostscript  may be built to use many different output devices.  To see
36       which devices your executable includes, run "gs -h".
37
38       Unless you specify a particular device, Ghostscript normally opens  the
39       first one of those and directs output to it.
40
41       If  built  with  X11 support, often the default device is an X11 window
42       (previewer), else ghostscript will typically use the  bbox  device  and
43       print on stdout the dimension of the postscript file.
44
45       So  if the first one in the list is the one you want to use, just issue
46       the command
47
48            gs myfile.ps
49
50       You can also check the set of  available  devices  from  within  Ghost‐
51       script: invoke Ghostscript and type
52
53            devicenames ==
54
55       but  the  first device on the resulting list may not be the default de‐
56       vice you determine with "gs -h".  To specify "AbcXyz"  as  the  initial
57       output device, include the switch
58
59            -sDEVICE=AbcXyz
60
61       For example, for output to an Epson printer you might use the command
62
63            gs -sDEVICE=epson myfile.ps
64
65       The  "-sDEVICE="  switch  must  precede  the first mention of a file to
66       print, and only the switch's first use has any effect.
67
68       Finally, you can specify a default device in the  environment  variable
69       GS_DEVICE.  The order of precedence for these alternatives from highest
70       to lowest (Ghostscript uses the device defined highest in the list) is:
71
72       Some devices can support different resolutions (densities).  To specify
73       the resolution on such a printer, use the "-r" switch:
74
75            gs -sDEVICE=<device> -r<xres>x<yres>
76
77       For  example,  on a 9-pin Epson-compatible printer, you get the lowest-
78       density (fastest) mode with
79
80            gs -sDEVICE=epson -r60x72
81
82       and the highest-density (best output quality) mode with
83
84            gs -sDEVICE=epson -r240x72.
85
86       If you select a printer as the output device, Ghostscript  also  allows
87       you  to  choose  where Ghostscript sends the output -- on Unix systems,
88       usually to a temporary file.  To send the output to a  file  "foo.xyz",
89       use the switch
90
91            -sOutputFile=foo.xyz
92
93       You  might  want  to  print each page separately.  To do this, send the
94       output to a series of files "foo1.xyz, foo2.xyz, ..." using the "-sOut‐
95       putFile=" switch with "%d" in a filename template:
96
97            -sOutputFile=foo%d.xyz
98
99       Each resulting file receives one page of output, and the files are num‐
100       bered in sequence.  "%d" is a printf format specification; you can also
101       use a variant like "%02d".
102
103       On Unix and MS Windows systems you can also send output to a pipe.  For
104       example, to pipe output to the "lpr" command (which, on many Unix  sys‐
105       tems, directs it to a printer), use the option
106
107            -sOutputFile=%pipe%lpr
108
109       Note  that the '%' characters need to be doubled on MS Windows to avoid
110       mangling by the command interpreter.
111
112       You can also send output to standard output:
113
114            -sOutputFile=-
115       or
116            -sOutputFile=%stdout%
117
118       In this case you must also use the -q switch,  to  prevent  Ghostscript
119       from writing messages to standard output.
120
121       To select a specific paper size, use the command line switch
122
123            -sPAPERSIZE=<paper_size>
124
125       for instance
126
127            -sPAPERSIZE=a4
128       or
129            -sPAPERSIZE=legal
130
131       Most ISO and US paper sizes are recognized. See the usage documentation
132       for a  full  list,  or  the  definitions  in  the  initialization  file
133       "gs_statd.ps".
134
135       Ghostscript  can do many things other than print or view PostScript and
136       PDF files.  For example, if you want to know  the  bounding  box  of  a
137       PostScript  (or EPS) file, Ghostscript provides a special "device" that
138       just prints out this information.
139
140       For example, using one of the example  files  distributed  with  Ghost‐
141       script,
142
143            gs -sDEVICE=bbox golfer.ps
144
145       prints out
146
147            %%BoundingBox: 0 25 583 732
148            %%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445
149

OPTIONS

151       -- filename arg1 ...
152              Takes  the  next argument as a file name as usual, but takes all
153              remaining arguments (even if they have  the  syntactic  form  of
154              switches)  and  defines  the name "ARGUMENTS" in "userdict" (not
155              "systemdict") as an array of those strings, before  running  the
156              file.   When  Ghostscript  finishes executing the file, it exits
157              back to the shell.
158
159       -Dname=token
160       -dname=token
161              Define a name in "systemdict" with the  given  definition.   The
162              token must be exactly one token (as defined by the "token" oper‐
163              ator) and may contain no whitespace.
164
165       -Dname
166       -dname Define a name in "systemdict" with value=null.
167
168       -Sname=string
169       -sname=string
170              Define a name in "systemdict" with  a  given  string  as  value.
171              This is different from -d.  For example, -dname=35 is equivalent
172              to the program fragment
173                   /name 35 def
174              whereas -sname=35 is equivalent to
175                   /name (35) def
176
177       -P     Makes Ghostscript to look first in the current directory for li‐
178              brary  files.   By  default,  Ghostscript no longer looks in the
179              current directory, unless, of course, the first explicitly  sup‐
180              plied directory is "." in -I.  See also the INITIALIZATION FILES
181              section below, and bundled Use.htm for  detailed  discussion  on
182              search paths and how Ghostcript finds files.
183
184       -q     Quiet startup: suppress normal startup messages, and also do the
185              equivalent of -dQUIET.
186
187       -gnumber1xnumber2
188              Equivalent to -dDEVICEWIDTH=number1 and  -dDEVICEHEIGHT=number2.
189              This  is  for  the benefit of devices (such as X11 windows) that
190              require (or allow) width and height to be specified.
191
192       -rnumber
193       -rnumber1xnumber2
194              Equivalent to -dDEVICEXRESOLUTION=number1  and  -dDEVICEYRESOLU‐
195              TION=number2.  This is for the benefit of devices such as print‐
196              ers that support multiple X and Y resolutions.  If only one num‐
197              ber is given, it is used for both X and Y resolutions.
198
199       -Idirectories
200              Adds  the  designated  list  of  directories  at the head of the
201              search path for library files.
202
203       -      This is not really a switch, but indicates to  Ghostscript  that
204              standard  input is coming from a file or a pipe and not interac‐
205              tively from the command line.  Ghostscript reads  from  standard
206              input  until it reaches end-of-file, executing it like any other
207              file, and then continues with processing the command line.  When
208              the  command line has been entirely processed, Ghostscript exits
209              rather than going into its interactive mode.
210
211       Note that the normal initialization file  "gs_init.ps"  makes  "system‐
212       dict"  read-only, so the values of names defined with -D, -d, -S, or -s
213       cannot be changed (although, of course, they can be superseded by defi‐
214       nitions in "userdict" or other dictionaries.)
215

SPECIAL NAMES

217       -dNOCACHE
218              Disables character caching.  Useful only for debugging.
219
220       -dNOBIND
221              Disables the "bind" operator.  Useful only for debugging.
222
223       -dNODISPLAY
224              Suppresses the normal initialization of the output device.  This
225              may be useful when debugging.
226
227       -dNOPAUSE
228              Disables the prompt and pause at the end of each page.  This may
229              be  desirable  for applications where another program is driving
230              Ghostscript.
231
232       -dNOPLATFONTS
233              Disables the use of fonts supplied by  the  underlying  platform
234              (for  instance  X  Windows).  This may be needed if the platform
235              fonts look undesirably different from the scalable fonts.
236
237       -dSAFER
238              Restricts file operations the job can perform. Now  the  default
239              mode of operation.
240
241       -dWRITESYSTEMDICT
242              Leaves  "systemdict"  writable.   This is necessary when running
243              special utility programs, but is strongly discouraged as it  by‐
244              passes normal Postscript security measures.
245
246       -sDEVICE=device
247              Selects an alternate initial output device, as described above.
248
249       -sOutputFile=filename
250              Selects  an alternate output file (or pipe) for the initial out‐
251              put device, as described above.
252

SAFER MODE

254       The -dSAFER option restricts file system accesses to  those  files  and
255       directories  allowed  by  the  relevant  environment variables (such as
256       GS_LIB)  or  by  the  command  line  parameters   (see   https://ghost
257       script.com/doc/current/Use.htm for details).
258
259       SAFER mode is now the default mode of operation. Thus when running pro‐
260       grams that need to open files or set restricted parameters  you  should
261       pass the -dNOSAFER command line option or its synonym -dDELAYSAFER.
262
263       Running  with NOSAFER/DELAYSAFER (as the same suggests) loosens the se‐
264       curity and is thus recommended ONLY for debugging or in VERY controlled
265       workflows, and strongly NOT recommended in any other circumstances.
266

FILES

268       The  locations of many Ghostscript run-time files are compiled into the
269       executable when it is built.  On Unix  these  are  typically  based  in
270       /usr/local,  but  this may be different on your system.  Under DOS they
271       are typically based in C:\GS, but may be elsewhere, especially  if  you
272       install  Ghostscript  with GSview.  Run "gs -h" to find the location of
273       Ghostscript documentation on your system, from which you can  get  more
274       details.
275
276       /usr/local/share/ghostscript/#.##/*
277              Startup files, utilities, and basic font definitions
278
279       /usr/local/share/ghostscript/fonts/*
280              More font definitions
281
282       /usr/local/share/ghostscript/#.##/examples/*
283              Ghostscript demonstration files
284
285       /usr/local/share/ghostscript/#.##/doc/*
286              Diverse document files
287

INITIALIZATION FILES

289       When  looking for the initialization files "gs_*.ps", the files related
290       to fonts, or the file for the "run" operator, Ghostscript  first  tries
291       to  open the file with the name as given, using the current working di‐
292       rectory if no directory is specified.  If this fails, and the file name
293       doesn't  specify  an explicit directory or drive (for instance, doesn't
294       contain "/" on Unix systems or "\" on MS Windows systems),  Ghostscript
295       tries directories in this order:
296
297       1.  the  directories  specified  by the -I switches in the command line
298           (see below), if any;
299
300       2.  the directories specified by the GS_LIB  environment  variable,  if
301           any;
302
303       3.  the directories specified by the GS_LIB_DEFAULT macro in the Ghost‐
304           script makefile when the executable was built.  When gs is built on
305           Unix,    GS_LIB_DEFAULT    is    usually   "/usr/local/share/ghost‐
306           script/#.##:/usr/local/share/ghostscript/fonts" where "#.##" repre‐
307           sents the Ghostscript version number.
308
309       Each  of these (GS_LIB_DEFAULT, GS_LIB, and -I parameter) may be either
310       a single directory or a list of directories separated by ":".
311

ENVIRONMENT

313       GS_OPTIONS
314              String of options to be processed before the  command  line  op‐
315              tions
316
317       GS_DEVICE
318              Used to specify an output device
319
320       GS_FONTPATH
321              Path names used to search for fonts
322
323       GS_LIB Path names for initialization files and fonts
324
325       TEMP   Where temporary files are made
326

X RESOURCES

328       Ghostscript,  or  more  properly  the X11 display device, looks for the
329       following resources under the program name "Ghostscript":
330
331       borderWidth
332              The border width in pixels (default = 1).
333
334       borderColor
335              The name of the border color (default = black).
336
337       geometry
338              The window size and placement, WxH+X+Y (default is NULL).
339
340       xResolution
341              The number of x  pixels  per  inch  (default  is  computed  from
342              WidthOfScreen and WidthMMOfScreen).
343
344       yResolution
345              The  number  of  y  pixels  per  inch  (default is computed from
346              HeightOfScreen and HeightMMOfScreen).
347
348       useBackingPixmap
349              Determines whether backing store is to be used for  saving  dis‐
350              play window (default = true).
351
352       See  the  usage document for a more complete list of resources.  To set
353       these resources on Unix, put them in a file such as "~/.Xresources"  in
354       the following form:
355
356            Ghostscript*geometry:     612x792-0+0
357            Ghostscript*xResolution: 72
358            Ghostscript*yResolution: 72
359
360       Then merge these resources into the X server's resource database:
361
362            % xrdb -merge ~/.Xresources
363

SEE ALSO

365       The various Ghostscript document files (above), especially Use.htm.
366

BUGS

368       See    http://bugs.ghostscript.com/   and   the   Usenet   news   group
369       comp.lang.postscript.
370

VERSION

372       This document was last revised for Ghostscript version 10.02.1.
373

AUTHOR

375       Artifex Software, Inc. are  the  primary  maintainers  of  Ghostscript.
376       Russell  J.  Lang,  gsview at ghostgum.com.au, is the author of most of
377       the MS Windows code in Ghostscript.
378
379
380
38110.02.1                        01 November 2023                          GS(1)
Impressum