1GS(1) Ghostscript GS(1)
2
3
4
6 gs - Ghostscript (PostScript and PDF language interpreter and pre‐
7 viewer)
8
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
16 The gs (gswin32c, gswin32, gsos2) command invokes Ghostscript, an
17 interpreter of Adobe Systems' PostScript(tm) and Portable Document For‐
18 mat (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. The interpreter exits gracefully when it encounters the
22 "quit" command (either in a file or from the keyboard), at end-of-file,
23 or at an interrupt signal (such as Control-C at the keyboard).
24
25 The interpreter recognizes many option switches, some of which are
26 described below. Please see the usage documentation for complete infor‐
27 mation. Switches may appear anywhere in the command line and apply to
28 all files thereafter. Invoking Ghostscript with the -h or -? switch
29 produces a message which shows several useful switches, all the devices
30 known to that executable, and the search path for fonts; on Unix it
31 also shows the location of detailed documentation.
32
33 Ghostscript may be built to use many different output devices. To see
34 which devices your executable includes, run "gs -h". Unless you spec‐
35 ify a particular device, Ghostscript normally opens the first one of
36 those and directs output to it, so if the first one in the list is the
37 one you want to use, just issue the command
38
39 gs myfile.ps
40
41 You can also check the set of available devices from within Ghost‐
42 script: invoke Ghostscript and type
43
44 devicenames ==
45
46 but the first device on the resulting list may not be the default
47 device you determine with "gs -h". To specify "AbcXyz" as the initial
48 output device, include the switch
49
50 -sDEVICE=AbcXyz
51
52 For example, for output to an Epson printer you might use the command
53
54 gs -sDEVICE=epson myfile.ps
55
56 The "-sDEVICE=" switch must precede the first mention of a file to
57 print, and only the switch's first use has any effect.
58
59 Finally, you can specify a default device in the environment variable
60 GS_DEVICE. The order of precedence for these alternatives from highest
61 to lowest (Ghostscript uses the device defined highest in the list) is:
62
63 Some devices can support different resolutions (densities). To specify
64 the resolution on such a printer, use the "-r" switch:
65
66 gs -sDEVICE=<device> -r<xres>x<yres>
67
68 For example, on a 9-pin Epson-compatible printer, you get the lowest-
69 density (fastest) mode with
70
71 gs -sDEVICE=epson -r60x72
72
73 and the highest-density (best output quality) mode with
74
75 gs -sDEVICE=epson -r240x72.
76
77 If you select a printer as the output device, Ghostscript also allows
78 you to choose where Ghostscript sends the output -- on Unix systems,
79 usually to a temporary file. To send the output to a file "foo.xyz",
80 use the switch
81
82 -sOutputFile=foo.xyz
83
84 You might want to print each page separately. To do this, send the
85 output to a series of files "foo1.xyz, foo2.xyz, ..." using the "-sOut‐
86 putFile=" switch with "%d" in a filename template:
87
88 -sOutputFile=foo%d.xyz
89
90 Each resulting file receives one page of output, and the files are num‐
91 bered in sequence. "%d" is a printf format specification; you can also
92 use a variant like "%02d".
93
94 On Unix and MS Windows systems you can also send output to a pipe. For
95 example, to pipe output to the "lpr" command (which, on many Unix sys‐
96 tems, directs it to a printer), use the option
97
98 -sOutputFile=%pipe%lpr
99
100 Note that the '%' characters need to be doubled on MS Windows to avoid
101 mangling by the command interpreter.
102
103 You can also send output to standard output:
104
105 -sOutputFile=-
106 or
107 -sOutputFile=%stdout%
108
109 In this case you must also use the -q switch, to prevent Ghostscript
110 from writing messages to standard output.
111
112 To select a specific paper size, use the command line switch
113
114 -sPAPERSIZE=<paper_size>
115
116 for instance
117
118 -sPAPERSIZE=a4
119 or
120 -sPAPERSIZE=legal
121
122 Most ISO and US paper sizes are recognized. See the usage documentation
123 for a full list, or the definitions in the initialization file
124 "gs_statd.ps".
125
126 Ghostscript can do many things other than print or view PostScript and
127 PDF files. For example, if you want to know the bounding box of a
128 PostScript (or EPS) file, Ghostscript provides a special "device" that
129 just prints out this information.
130
131 For example, using one of the example files distributed with Ghost‐
132 script,
133
134 gs -sDEVICE=bbox golfer.ps
135
136 prints out
137
138 %%BoundingBox: 0 25 583 732
139 %%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445
140
142 -- filename arg1 ...
143 Takes the next argument as a file name as usual, but takes all
144 remaining arguments (even if they have the syntactic form of
145 switches) and defines the name "ARGUMENTS" in "userdict" (not
146 "systemdict") as an array of those strings, before running the
147 file. When Ghostscript finishes executing the file, it exits
148 back to the shell.
149
150 -Dname=token
151 -dname=token
152 Define a name in "systemdict" with the given definition. The
153 token must be exactly one token (as defined by the "token" oper‐
154 ator) and may contain no whitespace.
155
156 -Dname
157 -dname Define a name in "systemdict" with value=null.
158
159 -Sname=string
160 -sname=string
161 Define a name in "systemdict" with a given string as value.
162 This is different from -d. For example, -dname=35 is equivalent
163 to the program fragment
164 /name 35 def
165 whereas -sname=35 is equivalent to
166 /name (35) def
167
168 -P Makes Ghostscript to look first in the current directory for
169 library files. By default, Ghostscript no longer looks in the
170 current directory, unless, of course, the first explicitly sup‐
171 plied directory is "." in -I. See also the INITIALIZATION FILES
172 section below, and bundled Use.htm for detailed discussion on
173 search paths and how Ghostcript finds files. -q Quiet startup:
174 suppress normal startup messages, and also do the equivalent of
175 -dQUIET.
176
177 -gnumber1xnumber2
178 Equivalent to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2.
179 This is for the benefit of devices (such as X11 windows) that
180 require (or allow) width and height to be specified.
181
182 -rnumber
183 -rnumber1xnumber2
184 Equivalent to -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLU‐
185 TION=number2. This is for the benefit of devices such as print‐
186 ers that support multiple X and Y resolutions. If only one num‐
187 ber is given, it is used for both X and Y resolutions.
188
189 -Idirectories
190 Adds the designated list of directories at the head of the
191 search path for library files.
192
193 - This is not really a switch, but indicates to Ghostscript that
194 standard input is coming from a file or a pipe and not interac‐
195 tively from the command line. Ghostscript reads from standard
196 input until it reaches end-of-file, executing it like any other
197 file, and then continues with processing the command line. When
198 the command line has been entirely processed, Ghostscript exits
199 rather than going into its interactive mode.
200
201 Note that the normal initialization file "gs_init.ps" makes "system‐
202 dict" read-only, so the values of names defined with -D, -d, -S, or -s
203 cannot be changed (although, of course, they can be superseded by defi‐
204 nitions in "userdict" or other dictionaries.)
205
207 -dDISKFONTS
208 Causes individual character outlines to be loaded from the disk
209 the first time they are encountered. (Normally Ghostscript
210 loads all the character outlines when it loads a font.) This
211 may allow loading more fonts into RAM, at the expense of slower
212 rendering.
213
214 -dNOCACHE
215 Disables character caching. Useful only for debugging.
216
217 -dNOBIND
218 Disables the "bind" operator. Useful only for debugging.
219
220 -dNODISPLAY
221 Suppresses the normal initialization of the output device. This
222 may be useful when debugging.
223
224 -dNOPAUSE
225 Disables the prompt and pause at the end of each page. This may
226 be desirable for applications where another program is driving
227 Ghostscript.
228
229 -dNOPLATFONTS
230 Disables the use of fonts supplied by the underlying platform
231 (for instance X Windows). This may be needed if the platform
232 fonts look undesirably different from the scalable fonts.
233
234 -dSAFER
235 Disables the "deletefile" and "renamefile" operators and the
236 ability to open files in any mode other than read-only. This
237 strongly recommended for spoolers, conversion scripts or other
238 sensitive environments where a badly written or malicious Post‐
239 Script program code must be prevented from changing important
240 files.
241
242 -dWRITESYSTEMDICT
243 Leaves "systemdict" writable. This is necessary when running
244 special utility programs such as font2c and pcharstr, which must
245 bypass normal PostScript access protection.
246
247 -sDEVICE=device
248 Selects an alternate initial output device, as described above.
249
250 -sOutputFile=filename
251 Selects an alternate output file (or pipe) for the initial out‐
252 put device, as described above.
253
255 The locations of many Ghostscript run-time files are compiled into the
256 executable when it is built. On Unix these are typically based in
257 /usr/local, but this may be different on your system. Under DOS they
258 are typically based in C:\GS, but may be elsewhere, especially if you
259 install Ghostscript with GSview. Run "gs -h" to find the location of
260 Ghostscript documentation on your system, from which you can get more
261 details.
262
263 /usr/local/share/ghostscript/#.##/*
264 Startup files, utilities, and basic font definitions
265
266 /usr/local/share/ghostscript/fonts/*
267 More font definitions
268
269 /usr/local/share/ghostscript/#.##/examples/*
270 Ghostscript demonstration files
271
272 /usr/local/share/ghostscript/#.##/doc/*
273 Diverse document files
274
276 When looking for the initialization files "gs_*.ps", the files related
277 to fonts, or the file for the "run" operator, Ghostscript first tries
278 to open the file with the name as given, using the current working
279 directory if no directory is specified. If this fails, and the file
280 name doesn't specify an explicit directory or drive (for instance,
281 doesn't contain "/" on Unix systems or "\" on MS Windows systems),
282 Ghostscript tries directories in this order:
283
284 1. the directories specified by the -I switches in the command line
285 (see below), if any;
286
287 2. the directories specified by the GS_LIB environment variable, if
288 any;
289
290 3. the directories specified by the GS_LIB_DEFAULT macro in the Ghost‐
291 script makefile when the executable was built. When gs is built on
292 Unix, GS_LIB_DEFAULT is usually "/usr/local/share/ghost‐
293 script/#.##:/usr/local/share/ghostscript/fonts" where "#.##" repre‐
294 sents the Ghostscript version number.
295
296 Each of these (GS_LIB_DEFAULT, GS_LIB, and -I parameter) may be either
297 a single directory or a list of directories separated by ":".
298
300 GS_OPTIONS
301 String of options to be processed before the command line
302 options
303
304 GS_DEVICE
305 Used to specify an output device
306
307 GS_FONTPATH
308 Path names used to search for fonts
309
310 GS_LIB Path names for initialization files and fonts
311
312 TEMP Where temporary files are made
313
315 Ghostscript, or more properly the X11 display device, looks for the
316 following resources under the program name "Ghostscript":
317
318 borderWidth
319 The border width in pixels (default = 1).
320
321 borderColor
322 The name of the border color (default = black).
323
324 geometry
325 The window size and placement, WxH+X+Y (default is NULL).
326
327 xResolution
328 The number of x pixels per inch (default is computed from
329 WidthOfScreen and WidthMMOfScreen).
330
331 yResolution
332 The number of y pixels per inch (default is computed from
333 HeightOfScreen and HeightMMOfScreen).
334
335 useBackingPixmap
336 Determines whether backing store is to be used for saving dis‐
337 play window (default = true).
338
339 See the usage document for a more complete list of resources. To set
340 these resources on Unix, put them in a file such as "~/.Xresources" in
341 the following form:
342
343 Ghostscript*geometry: 612x792-0+0
344 Ghostscript*xResolution: 72
345 Ghostscript*yResolution: 72
346
347 Then merge these resources into the X server's resource database:
348
349 % xrdb -merge ~/.Xresources
350
352 The various Ghostscript document files (above), especially Use.htm.
353
355 See http://bugs.ghostscript.com/ and the Usenet news group
356 comp.lang.postscript.
357
359 This document was last revised for Ghostscript version 8.70.
360
362 Artifex Software, Inc. are the primary maintainers of Ghostscript.
363 Russell J. Lang, gsview at ghostgum.com.au, is the author of most of
364 the MS Windows code in Ghostscript.
365
366
367
3688.70 31 July 2009 GS(1)