Debian Codegraph @

man/gs.1

raw ◀ ▶
Source reconstructed at patch state 0 of 5 — not the installed (fully patched) source.
5 Debian patches touch this file
1 .TH GS 1 "18 Sept 2024" 10.04.0 Ghostscript \" -*- nroff -*-
2 .SH NAME
3 gs \- Ghostscript (PostScript and PDF language interpreter and previewer)
4 .SH SYNOPSIS
5 \fBgs\fR [ \fIoptions\fR ] [ \fIfiles\fR ] ... \fB(Unix, VMS)\fR
6 .br
7 \fBgswin32c\fR [ \fIoptions\fR ] [ \fIfiles\fR ] ... \fB(MS Windows)\fR
8 .br
9 \fBgswin32\fR [ \fIoptions\fR ] [ \fIfiles\fR ] ... \fB(MS Windows 3.1)\fR
10 .br
11 \fBgsos2\fR [ \fIoptions\fR ] [ \fIfiles\fR ] ... \fB(OS/2)\fR
12 .de TQ
13 .br
14 .ns
15 .TP \\$1
16 ..
17 .SH DESCRIPTION
18 The \fBgs\fR (\fBgswin32c\fR, \fBgswin32\fR, \fBgsos2\fR)
19 command invokes \fBGhostscript\fR, an interpreter of Adobe Systems'
20 \fBPostScript\fR(tm) and \fBPortable Document Format\fR (PDF) languages.
21 \fBgs\fR reads "files" in sequence and executes them as Ghostscript
22 programs. After doing this, it reads further input from the standard input
23 stream (normally the keyboard), interpreting each line separately and
24 output to an output device (may be a file or an X11 window preview,
25 see below). The
26 interpreter exits gracefully when it encounters the "quit" command (either
27 in a file or from the keyboard), at end-of-file, or at an interrupt signal
28 (such as Control-C at the keyboard).
29 .PP
30 The interpreter recognizes many option switches, some of which are described
31 below. Please see the usage documentation for complete information. Switches
32 may appear anywhere in the command line and apply to all files thereafter.
33 Invoking Ghostscript with the \fB\-h\fR or \fB\-?\fR switch produces a
34 message which shows several useful switches, all the devices known to
35 that executable, and the search path for fonts; on Unix it also shows the
36 location of detailed documentation.
37 .PP
38 Ghostscript may be built to use many different output devices. To see
39 which devices your executable includes, run "\fBgs -h\fR".
40 .PP
41 Unless you
42 specify a particular device, Ghostscript normally opens the first one of
43 those and directs output to it.
44 .PP
45 If built with X11 support, often
46 the default device is an X11 window (previewer), else ghostscript will
47 typically
48 use the bbox device and print on stdout the dimension of the postscript file.
49 .PP
50 So if the first one in the list is the one
51 you want to use, just issue the command
52 .PP
53 .nf
54 gs myfile.ps
55 .fi
56 .PP
57 You can also check the set of available devices from within Ghostscript:
58 invoke Ghostscript and type
59 .PP
60 .nf
61 devicenames ==
62 .fi
63 .PP
64 but the first device on the resulting list may not be the default device
65 you determine with "\fBgs -h\fR". To specify "AbcXyz" as the
66 initial output device, include the switch
67 .PP
68 .nf
69 \-sDEVICE=AbcXyz
70 .fi
71 .PP
72 For example, for output to an Epson printer you might use the command
73 .PP
74 .nf
75 gs \-sDEVICE=epson myfile.ps
76 .fi
77 .PP
78 The "\-sDEVICE=" switch must precede the first mention of a file to print,
79 and only the switch's first use has any effect.
80 .PP
81 Finally, you can specify a default device in the environment variable
82 \fBGS_DEVICE\fR. The order of precedence for these alternatives from
83 highest to lowest (Ghostscript uses the device defined highest in the list)
84 is:
85 .PP
86 .nf
87 setpagedevice
88 (command line)
89 GS_DEVICE
90 (first device in build list)
91 .fi
92 .PP
93 Some devices can support different resolutions (densities). To specify
94 the resolution on such a device, use the "\-r" switch:
95 .PP
96 .nf
97 gs \-sDEVICE=<device> \-r<xres>x<yres>
98 .fi
99 .PP
100 For example, on a 9-pin Epson-compatible printer, you get the
101 lowest-density (fastest) mode with
102 .PP
103 .nf
104 gs \-sDEVICE=epson \-r60x72
105 .fi
106 .PP
107 and the highest-density (best output quality) mode with
108 .PP
109 .nf
110 gs \-sDEVICE=epson \-r240x72.
111 .fi
112 .PP
113 If you select a printer as the output device, Ghostscript also allows you
114 to choose where Ghostscript sends the output \-\- on Unix systems, usually
115 to a temporary file. To send the output to a file "foo.xyz",
116 use the switch
117 .PP
118 .nf
119 \-sOutputFile=foo.xyz
120 .fi
121 .PP
122 You might want to print each page separately. To do this, send the output
123 to a series of files "foo1.xyz, foo2.xyz, ..." using the "\-sOutputFile="
124 switch with "%d" in a filename template:
125 .PP
126 .nf
127 \-sOutputFile=foo%d.xyz
128 .fi
129 .PP
130 Each resulting file receives one page of output, and the files are numbered
131 in sequence. "%d" is a printf format specification; you can also use a
132 variant like "%02d".
133 .PP
134 On Unix and MS Windows systems you can also send output to a pipe. For example, to
135 pipe output to the "\fBlpr\fR" command (which, on many Unix systems,
136 directs it to a printer), use the option
137 .PP
138 .nf
139 \-sOutputFile=%pipe%lpr
140 .fi
141 .PP
142 Note that the '%' characters need to be doubled on MS Windows to avoid
143 mangling by the command interpreter.
144 .PP
145 You can also send output to standard output:
146 .PP
147 .nf
148 \-sOutputFile=\-
149 .fi
150 or
151 .nf
152 \-sOutputFile=%stdout%
153 .fi
154 .PP
155 In this case you must also use the \fB\-q\fR switch, to prevent Ghostscript
156 from writing messages to standard output.
157 .PP
158 To select a specific paper size, use the command line switch
159 .PP
160 .nf
161 -sPAPERSIZE=<paper_size>
162 .fi
163 .PP
164 for instance
165 .PP
166 .nf
167 -sPAPERSIZE=a4
168 .fi
169 or
170 .nf
171 -sPAPERSIZE=legal
172 .fi
173 .PP
174 Most ISO and US paper sizes are recognized. See the usage documentation for
175 a full list, or the definitions in the initialization file "gs_statd.ps".
176 .PP
177 Ghostscript can do many things other than print or view PostScript and
178 PDF files. For example, if you want to know the bounding box of a
179 PostScript (or EPS) file, Ghostscript provides a special "device" that
180 just prints out this information.
181 .PP
182 For example, using one of the example files distributed with Ghostscript,
183 .PP
184 .nf
185 gs \-sDEVICE=bbox golfer.ps
186 .fi
187 .PP
188 prints out
189 .PP
190 .nf
191 %%BoundingBox: 0 25 583 732
192 %%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445
193 .fi
194 .SH OPTIONS
195 .TP
196 .BI \-\- " filename arg1 ..."
197 Takes the next argument as a file name as usual, but takes all remaining
198 arguments (even if they have the syntactic form of switches) and defines
199 the name "ARGUMENTS" in "userdict" (not "systemdict") as an
200 array of those strings, \fBbefore\fR running the file. When Ghostscript
201 finishes executing the file, it exits back to the shell.
202 .TP
203 .BI \-D name = token
204 .TQ
205 .BI \-d name = token
206 Define a name in "systemdict" with the given definition. The token must be
207 exactly one token (as defined by the "token" operator) and may contain no
208 whitespace.
209 .TP
210 .BI \-D name
211 .TQ
212 .BI \-d name
213 Define a name in "systemdict" with value=null.
214 .TP
215 .BI \-S name = string
216 .TQ
217 .BI \-s name = string
218 Define a name in "systemdict" with a given string as value. This is
219 different from \fB\-d\fR. For example, \fB\-dname=35\fR is equivalent to the
220 program fragment
221 .br
222 /name 35 def
223 .br
224 whereas \fB\-sname=35\fR is equivalent to
225 .br
226 /name (35) def
227 .TP
228 .B \-P
229 Makes Ghostscript to look first in the current directory for library files.
230 By default, Ghostscript no longer looks in the current directory,
231 unless, of course, the first explicitly supplied directory is "." in \fB-I\fR.
232 See also the \fBINITIALIZATION FILES\fR section below, and bundled
233 \fBUse.htm\fR for detailed discussion on search paths and how Ghostcript finds files.
234 .TP
235 .B \-q
236 Quiet startup: suppress normal startup messages, and also do the
237 equivalent of \fB\-dQUIET\fR.
238 .TP
239 .BI \-g number1 x number2
240 Equivalent to \fB\-dDEVICEWIDTH=\fR\fInumber1\fR and
241 \fB\-dDEVICEHEIGHT=\fR\fInumber2\fR. This is for the benefit of devices
242 (such as X11 windows) that require (or allow) width and height to be
243 specified.
244 .TP
245 .BI \-r number
246 .TQ
247 .BI \-r number1 x number2
248 Equivalent to \fB\-dDEVICEXRESOLUTION=\fR\fInumber1\fR and
249 \fB\-dDEVICEYRESOLUTION=\fR\fInumber2\fR. This is for the benefit of
250 devices such as printers that support multiple X and Y resolutions. If
251 only one number is given, it is used for both X and Y resolutions.
252 .TP
253 .BI \-I directories
254 Adds the designated list of directories at the head of the
255 search path for library files.
256 .TP
257 .B \-
258 This is not really a switch, but indicates to Ghostscript that standard
259 input is coming from a file or a pipe and not interactively from the
260 command line. Ghostscript reads from standard input until it reaches
261 end-of-file, executing it like any other file, and then continues with
262 processing the command line. When the command line has been entirely
263 processed, Ghostscript exits rather than going into its interactive mode.
264 .PP
265 Note that the normal initialization file "gs_init.ps" makes "systemdict"
266 read-only, so the values of names defined with \fB\-D\fR, \fB\-d\fR,
267 \fB\-S\fR, or \fB\-s\fR cannot be changed (although, of course, they can be
268 superseded by definitions in "userdict" or other dictionaries.)
269 .SH "SPECIAL NAMES"
270 .TP
271 .B \-dNOCACHE
272 Disables character caching. Useful only for debugging.
273 .TP
274 .B \-dNOBIND
275 Disables the "bind" operator. Useful only for debugging.
276 .TP
277 .B \-dNODISPLAY
278 Suppresses the normal initialization of the output device.
279 This may be useful when debugging.
280 .TP
281 .B \-dNOPAUSE
282 Disables the prompt and pause at the end of each page. This may be
283 desirable for applications where another program is driving Ghostscript.
284 .TP
285 .B \-dNOPLATFONTS
286 Disables the use of fonts supplied by the underlying platform (for instance
287 X11). This may be needed if the platform fonts look undesirably
288 different from the scalable fonts.
289 .TP
290 .B \-dSAFER
291 Restricts file operations the job can perform. Now the default mode of operation.
292 .TP
293 .B \-dWRITESYSTEMDICT
294 Leaves "systemdict" writable. This is necessary when running special
295 utility programs, but is strongly discouraged as it bypasses normal Postscript
296 security measures.
297 .TP
298 .BI \-sDEVICE= device
299 Selects an alternate initial output device, as described above.
300 .TP
301 .BI \-sOutputFile= filename
302 Selects an alternate output file (or pipe) for the initial output
303 device, as described above.
304 .SH "SAFER MODE"
305 .PP
306 The
307 .B \-dSAFER
308 option restricts file system accesses to those files and directories
309 allowed by the relevant environment variables (such as GS_LIB) or
310 by the command line parameters (see https://ghostscript.com/doc/current/Use.htm
311 for details).
312 .PP
313 SAFER mode is now the default mode of operation. Thus when running programs that
314 need to open files or set restricted parameters
315 you should pass the
316 .B \-dNOSAFER
317 command line option or its synonym
318 .BR \-dDELAYSAFER .
319 .PP
320 Running with NOSAFER/DELAYSAFER (as the name suggests) loosens the security
321 and is thus recommended ONLY for debugging or in VERY controlled workflows,
322 and strongly NOT recommended in any other circumstances.
323 .SH FILES
324 .PP
325 The locations of many Ghostscript run-time files are compiled into the
326 executable when it is built. On Unix these are typically based in
327 \fB/usr/local\fR, but this may be different on your system. Under DOS they
328 are typically based in \fBC:\\GS\fR, but may be elsewhere, especially if
329 you install Ghostscript with \fBGSview\fR. Run "\fBgs -h\fR" to find the
330 location of Ghostscript documentation on your system, from which you can
331 get more details.
332 .TP
333 .B /usr/local/share/ghostscript/#.##/*
334 Startup files, utilities, and basic font definitions
335 .TP
336 .B /usr/local/share/ghostscript/fonts/*
337 More font definitions
338 .TP
339 .B /usr/local/share/ghostscript/#.##/examples/*
340 Ghostscript demonstration files
341 .TP
342 .B /usr/local/share/ghostscript/#.##/doc/*
343 Diverse document files
344 .SH "INITIALIZATION FILES"
345 When looking for the initialization files "gs_*.ps", the files related to
346 fonts, or the file for the "run" operator, Ghostscript first tries to open
347 the file with the name as given, using the current working directory if no
348 directory is specified. If this fails, and the file name doesn't specify
349 an explicit directory or drive (for instance, doesn't contain "/" on Unix
350 systems or "\\" on MS Windows systems), Ghostscript tries directories in this
351 order:
352 .TP 4
353 1.
354 the directories specified by the \fB\-I\fR switches in the command
355 line (see below), if any;
356 .TP
357 2.
358 the directories specified by the \fBGS_LIB\fR environment variable,
359 if any;
360 .TP
361 3.
362 the directories specified by the \fBGS_LIB_DEFAULT\fR macro in the
363 Ghostscript makefile when the executable was built. When \fBgs\fR is built
364 on Unix, \fBGS_LIB_DEFAULT\fR is usually
365 "/usr/local/share/ghostscript/#.##:/usr/local/share/ghostscript/fonts"
366 where "#.##" represents the Ghostscript version number.
367 .PP
368 Each of these (\fBGS_LIB_DEFAULT\fR, \fBGS_LIB\fR, and \fB\-I\fR parameter)
369 may be either a single directory or a list of directories separated by
370 ":".
371 .SH ENVIRONMENT
372 .TP
373 .B GS_OPTIONS
374 String of options to be processed before the command line options
375 .TP
376 .B GS_DEVICE
377 Used to specify an output device
378 .TP
379 .B GS_FONTPATH
380 Path names used to search for fonts
381 .TP
382 .B GS_LIB
383 Path names for initialization files and fonts
384 .TP
385 .B TEMP
386 Where temporary files are made
387 .SH X RESOURCES
388 Ghostscript, or more properly the X11 display device, looks for the
389 following resources under the program name "Ghostscript":
390 .TP
391 .B borderWidth
392 The border width in pixels (default = 1).
393 .TP
394 .B borderColor
395 The name of the border color (default = black).
396 .TP
397 .B geometry
398 The window size and placement, WxH+X+Y (default is NULL).
399 .TP
400 .B xResolution
401 The number of x pixels per inch (default is computed from \fBWidthOfScreen\fR
402 and \fBWidthMMOfScreen\fR).
403 .TP
404 .B yResolution
405 The number of y pixels per inch (default is computed from
406 \fBHeightOfScreen\fR and \fBHeightMMOfScreen\fR).
407 .TP
408 .B useBackingPixmap
409 Determines whether backing store is to be used for saving display window
410 (default = true).
411 .PP
412 See the usage document for a more complete list of resources. To set these
413 resources on Unix, put them in a file such as /fI~/.Xresources/fR in the
414 following form:
415 .PP
416 .nf
417 Ghostscript*geometry: 612x792\-0+0
418 Ghostscript*xResolution: 72
419 Ghostscript*yResolution: 72
420 .fi
421 .PP
422 Then merge these resources into the X server's resource database:
423 .PP
424 .nf
425 % xrdb \-merge ~/.Xresources
426 .fi
427 .SH SEE ALSO
428 The various Ghostscript document files (above), especially \fBUse.htm\fR.
429 .SH BUGS
430 See http://bugs.ghostscript.com/ and the Usenet news group
431 comp.lang.postscript.
432 .SH VERSION
433 This document was last revised for Ghostscript version 10.04.0.
434 .SH AUTHOR
435 Artifex Software, Inc. are the primary maintainers
436 of Ghostscript.
437 Russell J. Lang, gsview at ghostgum.com.au, is the author of
438 most of the MS Windows code in Ghostscript.