GS(1)                                                       GS(1)

     NAME
          gs - Aladdin Ghostscript (PostScript and PDF language
          interpreter)

     SYNOPSIS
          gs [ options ] [ files ] ...

     DESCRIPTION
          Ghostscript is a programming language similar to Adobe Sys-
          tems' PostScript and PDF languages, which are in turn simi-
          lar 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, how-
          ever, it represents the standard input, which is read in
          order and not after the files on the command line.  Each
          line is interpreted separately.  The `quit' command, or
          end-of-file, exits the interpreter.

          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 default is plan9, which produces compressed
          image files suitable for viewing with page(1) (but note that
          page(1) will invoke gs automatically; 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 envi-
          ronment variable GS_DEVICE.  The order of precedence for
          these alternatives, highest to lowest, is:
               selectdevice
               (command line)
               GS_DEVICE
               plan9

          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 specifica-
          tion.  Each file will receive one page of output.  If the
          file name begins with a pipe character, the output will be

     Page 1                       Plan 9            (printed 11/22/24)

     GS(1)                                                       GS(1)

          sent as standard input to the following pipeline.  For exam-
          ple,
               -sOutputFile=|lp
          Specifying the file - will send the files to standard out-
          put; 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 direc-
          tories 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-separated list.

        Options
          -- filename arg1 ...
               Take the next argument as a file name as usual, but
               take all remaining arguments (even if they have the
               syntactic form of switches) and define the name ARGU-
               MENTS in userdict (not systemdict) 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 token must be exactly one token (as defined by the
               `token' operator) 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

     Page 2                       Plan 9            (printed 11/22/24)

     GS(1)                                                       GS(1)

               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 val-
          ues 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
          -dBATCH
               Exit after the last file has been processed.  This is
               equivalent to listing quit.ps at the end of the list of
               files.

          -dDISKFONTS
               Causes individual character outlines to be loaded from
               the disk the first time they are encountered.  (Nor-
               mally 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 debug-
               ging.

          -dNODISPLAY
               Suppresses the normal initialization of the output
               device.  This may be useful when debugging.

     Page 3                       Plan 9            (printed 11/22/24)

     GS(1)                                                       GS(1)

          -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 ability to open files in any mode other than read-
               only.  This may be desirable for spoolers or other sen-
               sitive environments.  Files in the /fd directory may
               still be opened for writing.

          -dWRITESYSTEMDICT
               Leaves systemdict writable.  This is necessary when
               running special 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 ini-
               tial output device, as described above.

     FILES
          /sys/lib/ghostscript/*
               Startup-files, utilities, examples, and basic font def-
               initions.

          /sys/lib/ghostscript/fonts/*
               Additional font definitions.

     SOURCE
          /sys/src/cmd/gs

     SEE ALSO
          page(1), ps2pdf(1)
          The Ghostscript document files in doc and man subdirectories
          of the source directory.

     BUGS
          The treatment of standard input is non-standard.

     Page 4                       Plan 9            (printed 11/22/24)