gs(1) -- Linux man page

 

NAME

gs - Ghostscript (PostScript and PDF language interpreter and previewer)  

SYNOPSIS

gs [ options ] [ files ] ... (Unix, VMS)
gswin32 [ options ] [ files ] ... (MS Windows)
gswin32c [ options ] [ files ] ... (MS Windows)
gs386 [ options ] [ files ] ... (DOS for PC)
gsos2 [ options ] [ files ] ... (OS/2)  

DESCRIPTION

The gs (gswin32, gswin32c, gs386, gsos2) command invokes Ghostscript, an interpreter of Adobe Systems' PostScript(tm) and Portable Document Format (PDF) languages. gs reads "files" in sequence and executes them as Ghostscript programs. After doing this, it reads further input from the standard input stream (normally the keyboard), interpreting each line separately. The interpreter quits gracefully when it encounters the "quit" command (either in a file or from the keyboard), at end-of-file, or at an interrupt signal (such as Control-C at the keyboard).

The interpreter recognizes several switches described below, which may appear anywhere in the command line and apply to all files thereafter. Invoking Ghostscript with the -h or -? switch produces a message which shows several useful switches, all the devices known to that executable, and the search path for fonts; on Unix it also shows the location of detailed documentation.

Ghostscript may be built able to use many different output devices. To see which devices your executable can use, run "gs -h". Unless you specify a particular device, Ghostscript normally opens the first one of those and directs output to it, so if the first one in the list is the one you want to use, just issue the command

        gs myfile.ps

You can also check the set of available devices from within Ghostscript: invoke Ghostscript and type

        devicenames ==

but the first device on the resulting list may not be the default device you determine with "gs -h". To specify "AbcXyz" as the initial output device, include the switch

        -sDEVICE=AbcXyz

For example, for output to an Epson printer you might use the command

        gs -sDEVICE=epson myfile.ps

The "-sDEVICE=" switch must precede the first mention of a file to print, and only the switch's first use has any effect. Alternatively, in Ghostscript you can type

        (epson) selectdevice
        (myfile.ps) run

All output then goes to the printer until you select another device with the "selectdevice" procedure in the PostScript program stream, for example

        (vga) selectdevice
or
        (x11) selectdevice

Finally, you can specify a default device in the environment variable GS_DEVICE. The order of precedence for these alternatives from highest to lowest (Ghostscript uses the device defined highest in the list) is:

        selectdevice
        (command line)
        GS_DEVICE
        (first device in build list)

Some printers can print at different resolutions (densities). To specify the resolution on such a printer, use the "-r" switch:

        gs -sDEVICE=<device> -r<xres>x<yres>

For example, on a 9-pin Epson-compatible printer, you get the lowest-density (fastest) mode with

        gs -sDEVICE=epson -r60x72

and the highest-density (best output quality) mode with

        gs -sDEVICE=epson -r240x72.

If you select a printer as the output device, Ghostscript also allows you to choose where Ghostscript sends the output -- on Unix systems, usually to a temporary file. To send the output to a file "foo.xyz", use the switch

        -sOutputFile=foo.xyz

You might want to print each page separately. To do this, send the output to a series of files "foo1.xyz, foo2.xyz, ..." using the "-sOutputFile=" switch with "%d" in a filename template:

        -sOutputFile=foo%d.xyz

Each resulting file receives one page of output, and the files are numbered in sequence. "%d" is a printf format specification; you can also use a variant like "%02d".

On Unix systems you can also send output to a pipe. For example, to pipe output to the "lpr" command (which, on many Unix systems, directs it to a printer), use the switch

        -sOutputFile=\|lpr

You can also send output to standard output for piping with the switch

        -sOutputFile=-

In this case you must also use the -q switch, to prevent Ghostscript from writing messages to standard output.

To select a specific paper size, use the command line switch

        -sPAPERSIZE=a_known_paper_size

for instance

        -sPAPERSIZE=a4
or
        -sPAPERSIZE=legal

At this time, the known paper sizes, defined in the initialization file "gs_statd.ps", are:

PAPERSIZEX inchesY inchesX cmY cm