index.txt
GS(1) General Commands Manual GS(1) NAME gs - Aladdin Ghostscript (PostScript) interpreter SYNOPSIS gs [ options ] [ files ] ... DESCRIPTION Ghostscript is a programming language similar to Adobe Systems' Post‐ Script language, which is in turn similar to Forth. Gs reads files in sequence and executes them as Ghostscript programs. After doing this, it reads further input from the standard input. If the file - is named, however, it represents the standard input, which is read in or‐ der and not after the files on the command line. Each line is inter‐ preted separately. The `quit' command, or end-of-file, exits the in‐ terpreter. The interpreter recognizes several switches described below, which may appear anywhere in the command line and apply to all files thereafter. The -h or -? options give help and list the available devices; the de‐ fault is dfaxlow, which produces CCITT Group 3 fax files suitable for viewing with page(1) (but note that page(1) will invoke gs automati‐ cally; see its manual). 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 -sDEVICE=xyz in the command line. This switch must precede the first PostScript file and only its first invocation has any effect. Output devices can also be selected by the word selectdevice in the input language, or by setting the environment variable GS_DEVICE. The order of precedence for these alternatives, highest to lowest, is: selectdevice (command line) GS_DEVICE dfaxlow Normally, output goes directly to a scratch file. To send the output to a series of files foo1.xyz, foo2.xyz, etc., use the switch -sOUTPUTFILE=foo%d.xyz The %d may be any printf (see fprintf(2)) format specification. Each file will receive one page of output. If the file name begins with a pipe character, the output will be sent as standard input to the fol‐ lowing pipeline. For example, -sOUTPUTFILE=|lp Specifying the file - will send the files to standard output; this also requires enabling the -q option. Initialization files When looking for the initialization files (gs_*.ps), the files related to fonts, or the file for the run operator, Ghostscript first looks for the file (if it doesn't start with a slash) in the current directory, then in these directories in the following order: 1. Any directories specified by -I switches in the command line (see below); 2. Any directories specified by the GS_LIB environment variable; 3. The directories /sys/lib/ghostscript, /sys/lib/ghostscript/font, and /sys/lib/postscript/font. The GS_LIB or -I parameters may be a single directory or a colon-sepa‐ rated list. Options -- filename arg1 ... Take the next argument as a file name as usual, but take all re‐ maining arguments (even if they have the syntactic form of switches) and define the name ARGUMENTS in userdict (not system‐ dict) as an array of those strings, before running the file. When Ghostscript finishes executing the file, it exits back to the shell. -Dname=token -dname=token Define a name in systemdict with the given definition. The to‐ ken must be exactly one token (as defined by the `token' opera‐ tor) and must not contain any white space. -Dname -dname Define a name in systemdict with value=null. -Sname=string -sname=string Define a name in systemdict with a given string as value. This is different from -d. For example, -dname=35 is equivalent to the program fragment /name 35 def whereas -sname=35 is equivalent to /name (35) def -q Quiet startup: suppress normal startup messages, and also do the equivalent of -dQUIET. -gnumber1xnumber2 Equivalent to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2. This is for the benefit of devices, such as windows, that allow width and height to be specified. -rnumber -rnumber1xnumber2 Equivalent to -dDEVICEXRESOLUTION=number1 and -dDEVICE‐ YRESOLUTION= number2. 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. -Idirectories Adds the designated list of directories at the head of the search path for library files. 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.) Special names -dDISKFONTS 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. -dNOCACHE Disables character caching. Only useful for debugging. -dNOBIND Disables the `bind' operator. Only useful for debugging. -dNODISPLAY Suppresses the normal initialization of the output device. This may be useful when debugging. -dNOPAUSE Disables the prompt and pause at the end of each page. This may be desirable for applications where another program (e.g. page(1)) is `driving' Ghostscript. -dSAFER Disables the deletefile and renamefile operators, and the abil‐ ity to open files in any mode other than read-only. This may be desirable for spoolers or other sensitive environments. -dWRITESYSTEMDICT Leaves systemdict writable. This is necessary when running spe‐ cial utility programs such as font2c and pcharstr, which must bypass normal PostScript access protection. -sDEVICE=device Selects an alternate initial output device, as described above. -sOUTPUTFILE=filename Selects an alternate output file (or pipe) for the initial out‐ put device, as described above. FILES /sys/lib/ghostscript/* Startup-files, utilities, examples, and basic font definitions. /sys/lib/ghostscript/fonts/* Additional font definitions. SOURCE /sys/src/cmd/gs SEE ALSO page(1) The Ghostscript document files in the source directory. BUGS The treatment of standard input is non-standard. GS(1)