Debian Codegraph @

upstream/debian-unstable/man1/gs.1

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