这是一个测试的命令:gs -dQUIET -dNOSAFER -r300 -dBATCH -sDEVICE=pngalpha -dNOPAUSE -dNOPROMPT -sOutputFile=/opt/shanhy/testpng/%d.png /opt/shanhy/test.pdf

Linux 中,到文件gs所在目录执行。

Windows 中,到GhostScript安装目录下的bin目录下执行 gswin64c 或者 gswin32c(根据自己安装的版本)。





    "-dQUIET",    安静的意思,指代执行过程中尽可能少的输出日志等信息。(也可以简写为“-q”)
    "-dNOSAFER",    通过命令行运行
    "-dBATCH",    执行到最后一页后退出
    "-dNOPAUSE",    每一页转换之间没有停顿
    "-dNOPROMPT",    没有相关提示                       
    "-dFirstPage=1",    从第几页开始
    "-dLastPage=5",     到第几页结束  
    "-sDEVICE=pngalpha",    转换输出的文件类型装置,默认值为x11alpha
    "-g720x1280",    图片像素(-g<width>x<height>),一般不指定,使用默认输出
    "-r300",    图片分辨率(即图片解析度为300dpi),默认值好像是72(未测试证实)
    "-sOutputFile=/opt/shanhy/error1png/%d.png",    图片输出路径,使用%d或%ld输出页数


Default output device: x11alpha
Available devices:
   alc1900 alc2000 alc4000 alc4100 alc8500 alc8600 alc9100 ap3250 appledmp
   atx23 atx24 atx38 bbox bit bitcmyk bitrgb bitrgbtags bj10e bj10v bj10vh
   bj200 bjc600 bjc800 bjc880j bjccmyk bjccolor bjcgray bjcmono bmp16 bmp16m
   bmp256 bmp32b bmpgray bmpmono bmpsep1 bmpsep8 ccr cdeskjet cdj1600 cdj500
   cdj550 cdj670 cdj850 cdj880 cdj890 cdj970 cdjcolor cdjmono cdnj500 cfax
   chp2200 cif cljet5 cljet5c cljet5pr coslw2p coslwxl cp50 declj250 deskjet
   devicen dfaxhigh dfaxlow dj505j djet500 djet500c dl2100 dnj650c epl2050
   epl2050p epl2120 epl2500 epl2750 epl5800 epl5900 epl6100 epl6200 eplcolor
   eplmono eps2write eps9high eps9mid epson epsonc escp escpage faxg3
   faxg32d faxg4 fmlbp fmpr fpng fs600 gdi hl1240 hl1250 hl7x0 hpdj1120c
   hpdj310 hpdj320 hpdj340 hpdj400 hpdj500 hpdj500c hpdj510 hpdj520 hpdj540
   hpdj550c hpdj560c hpdj600 hpdj660c hpdj670c hpdj680c hpdj690c hpdj850c
   hpdj855c hpdj870c hpdj890c hpdjplus hpdjportable ibmpro ijs imagen
   inferno ink_cov inkcov itk24i itk38 iwhi iwlo iwlq jetp3852 jj100 jpeg
   jpegcmyk jpeggray la50 la70 la75 la75plus laserjet lbp310 lbp320 lbp8
   lex2050 lex3200 lex5700 lex7000 lips2p lips3 lips4 lips4v lj250 lj3100sw
   lj4dith lj4dithp lj5gray lj5mono ljet2p ljet3 ljet3d ljet4 ljet4d
   ljet4pjl ljetplus ln03 lp1800 lp1900 lp2000 lp2200 lp2400 lp2500 lp2563
   lp3000c lp7500 lp7700 lp7900 lp8000 lp8000c lp8100 lp8200c lp8300c
   lp8300f lp8400f lp8500c lp8600 lp8600f lp8700 lp8800c lp8900 lp9000b
   lp9000c lp9100 lp9200b lp9200c lp9300 lp9400 lp9500c lp9600 lp9600s
   lp9800c lps4500 lps6500 lq850 lxm3200 lxm5700m m8510 mag16 mag256
   md1xMono md2k md50Eco md50Mono md5k mgr4 mgr8 mgrgray2 mgrgray4 mgrgray8
   mgrmono miff24 mj500c mj6000c mj700v2c mj8000c ml600 necp6 npdl nullpage
   oce9050 oki182 oki4w okiibm oprp opvp paintjet pam pamcmyk32 pamcmyk4 pbm
   pbmraw pcl3 pcx16 pcx24b pcx256 pcx2up pcxcmyk pcxgray pcxmono pdfwrite
   pgm pgmraw pgnm pgnmraw photoex picty180 pj pjetxl pjxl pjxl300 pkm
   pkmraw pksm pksmraw plan plan9bm planc plang plank planm png16 png16m
   png256 png48 pngalpha pnggray pngmono pnm pnmraw ppm ppmraw pr1000
   pr1000_4 pr150 pr201 ps2write psdcmyk psdcmykog psdrgb pxlcolor pxlmono
   r4081 rinkj rpdl samsunggdi sgirgb sj48 spotcmyk st800 stcolor sunhmono
   t4693d2 t4693d4 t4693d8 tek4696 tiff12nc tiff24nc tiff32nc tiff48nc
   tiff64nc tiffcrle tiffg3 tiffg32d tiffg4 tiffgray tifflzw tiffpack
   tiffscaled tiffsep tiffsep1 txtwrite uniprint x11 x11alpha x11cmyk
   x11cmyk2 x11cmyk4 x11cmyk8 x11gray2 x11gray4 x11mono x11rg16x x11rg32x
   xcf xes xpswrite


How to use Ghostscript

Table of contents

For other information, see the Ghostscriptoverview and, if necessary, how toinstall Ghostscript.

Invoking Ghostscript

This document describes how to use the command line Ghostscript client.Ghostscript is also used as a general engine inside other applications (for viewing files for example).Please refer to the documentation for those applications for using Ghostscript in other contexts.

The command line to invoke Ghostscript isessentially the same on all systems, although the name of the executableprogram itself may differ among systems. For instance, to invokeGhostscript on unix-like systems type:

gs [options] {filename 1} ... [options] {filename N} ...

Here are some basic examples. The details of how these work are described below.

To view a file:

gs -dSAFER -dBATCH document.pdf
You'll be prompted to press return between pages.

To convert a figure to an image file:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 \
    -sOutputFile=tiger.png tiger.eps

To render the same image at 300 dpi:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 \
                -sOutputFile=tiger_300.png tiger.eps

To render a figure in grayscale:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -sOutputFile=figure.png figure.pdf

To rasterize a whole document:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pgmraw -r150 \
                -dTextAlphaBits=4 -sOutputFile='paper-%00d.pgm'

There are also a number of utility scripts for commonto convert a PostScript document to PDF:

The output is saved as file.pdf.

There are other utility scripts besides ps2pdf, including pdf2ps, ps2epsi, pdf2dsc, ps2ascii,ps2ps and ps2ps2. These just call Ghostscript with the appropriate(if complicated) set of options. You can use the 'ps2' set with eps files.

Ghostscript is capable of interpreting PostScript, encapsulated PostScript(EPS), DOS EPS (EPSF), and Adobe Portable Document Format (PDF). The interpreter reads and executes the files in sequence, using the method described under "File searching" to find them.

The interpreter runs in interactive mode by default. After processing the files given on the command line (if any) it reads further lines of PostScript language commands from the primary input stream, normally the keyboard, interpreting each line separately. To quit the interpreter, type "quit". The -dBATCH -dNOPAUSE options in the examples above disable the interactive prompting. The interpreter also quits gracefully if it encounters end-of-file or control-C.

The interpreter recognizes many options. An option may appear anywhere in the command line, and applies to all files named after it on the line. Many of them include "="followed by a parameter. The most important are described in detail here. Please see the reference sections on options and devices for a more complete listing.

Help at the command line: gs -h

You can get a brief help message by invoking Ghostscript with the-h or -? switch, like this:

gs -h
gs -?

The message shows for that version of the Ghostscript executable:

  • the version and release information
  • the general format of the command line
  • a few of the most useful options
  • the formats it can interpret
  • the available output devices
  • the search path
  • the bug report address

On other systems the executable may have a different name:

System   invocation name
Unix   gs
VMS   gs
MS Windows 95 and later   gswin32c
OS/2   gsos2

Selecting an output device

Ghostscript has a notion of 'output devices' which handle saving or displaying the results in a particular format. Ghostscript comes with a diverse variety of such devices supporting vector and raster file output, screen display, driving various printers and communicating with other applications.

The command line option '-sDEVICE=device' selects which output device Ghostscript should use. If this option isn't given the default device (usually a display device) is used. Ghostscript's built-in help message (gs -h) liststhe available output devices. For complete description of the devices distributed with Ghostscript and their options, please see the devices section of the documentation.

Note that this switch must precede the name of the first input file, andonly its first use has any effect. For example, for printer output in aconfiguration that includes an Epson printer driver, instead of just'gs' you might use

gs -sDEVICE=epson

The output device can also be set through the GS_DEVICE environment variable.

Once you invoke Ghostscriptyou can also find out what devices are available by typing'devicenames ==' at the interactive prompt.You can set the output device and process a file from the interactive prompt as well:

(epson) selectdevice
( run
All output then goes to the Epson printer instead of the display until youdo something to change devices. You can switch devices at any time byusing the selectdevice procedure, forinstance like one of these:
(x11alpha) selectdevice
(epson) selectdevice

Output resolution

Some printers can print at several different resolutions, letting youbalance resolution against printing speed. To select the resolution onsuch a printer, use the -r switch:

gs -sDEVICE=printer -rXRESxYRES
where XRES and YRES are the requested number of dots (or pixels) per inch. Where the two resolutions are same, as is the common case, you can simply use -rres.

The -r option is also useful for controlling the density of pixels when rasterizing to an image file. It is used this way in the examples at the beginning of this document.

Output to files

Ghostscript also allows you to control where it sends its output. With a display device this isn't necessary as the device handles presenting the output on screen internally. Some specialized printer drivers operate this way as well, but most devices are general and need to be directed to a particular file or printer.

To send the output to a file, use the -sOutputFile= switch or the -o switch (below).For instance, to direct all output into the file, use


When printing on MS Windows systems, output normally goes directly to the printer, PRN. On Unix and VMS systems it normally goes to a temporary file which is sent to the printer in a separate step. When using Ghostscript as a file rasterizer (converting PostScript or PDF to a raster image format) you will of course want to specify an appropriately named file for the output.

Ghostscript also accepts the special filename '-' which indicates the output should be written to standard output (the command shell).

Be aware that filenames beginning with the character % have a special meaning in PostScript. If you need to specify a file name that actuallybegins with %, you must prepend the %os% filedevice explicitly. For example to output to a file named %abc, you need to specify

gs -sOutputFile=%os%%abc
Please see Ghostscript and the PostScript Language and the PostScript Language Reference Manual for more details on % and filedevices.

Note that on MS Windows systems, the % character also has a special meaning for the command processor (shell), so you will have to double it.

gs -sOutputFile=%%os%%%%abc (on MS Windows)

Note, some devices (e.g. pdfwrite, ps2write, ...) only write the output fileupon exit, but changing the OutputFile device parameter will cause thesedevices to emit the pages received up to that point and then open the newfile name given by OutputFile.

For example, in order to create two PDF files from a single invocation ofghostscript the following can be used:

gs -sDEVICE=pdfwrite -o tiger.pdf examples/tiger.eps -c "<< /OutputFile (colorcir.pdf) >> setpagedevice" -f examples/

One page per file

Specifying a single output file works fine for printing and rasterizingfigures, but sometimes you want images of each page of a multi-pagedocument. You can tell Ghostscript to put each page of output in aseries of similarly named files. To do this place a template'%d' in the filename which Ghostscript will replace with thepage number.

Note: Since the % character is used to precede the page numberformat specification, in order to represent a file name that contains a %,double % characters must be used. For example for the file my%foothe OutputFile string needs to be my%%foo.

The format can in fact be more involved than a simple '%d'.The format specifier is of a form similar to the C printf format.The general form supported is:


    where:  flags    is one of:  #+-
            type     is one of:  diuoxX
For more information, please refer to documentation on the C printf formatspecifications. Some examples are:
produces 'ABC-1.png', ... , 'ABC-10.png', ...

produces 'ABC-001.pgm', ... , 'ABC-010.pgm', ...

produces 'ABC_p0001.tiff', ... , 'ABC_p0510.tiff', ... , 'ABC_p5238.tiff'

Note, however that the one page per file feature may not supported by all devices.Also, since some devices write output files when opened, there may be an extrablank page written (pdfwrite, ps2write, eps2write, pxlmono, pxlcolor, ...).

As noted above, when using MS Windows console ( or cmd.exe), youwill have to double the % character since the % is used bythat shell to prefix variables for substitution, e.g.,


-o option:

As a convenient shorthand you can use the -o option followed by the outputfile specification as discussed above. The -o option also sets the-dBATCH and -dNOPAUSE options.This is intended to be a quick way to invoke ghostscript to convert one or moreinput files.For instance, to convert to JPEG image files, one per page, use:

gs -sDEVICE=jpeg -o out-%d.jpg
is equivalent to:
gs -sDEVICE=jpeg -sOutputFile=out-%d.jpg -dBATCH -dNOPAUSE

Choosing paper size

Ghostscript is distributed configured to use U.S. letter paper as itsdefault page size. There are two ways to select other paper sizes from thecommand line:

  • If the desired paper size is listed in the section on paper sizes known to Ghostscript below, youcan select it as the default paper size for a single invocation ofGhostscript by using the -sPAPERSIZE= switch, for instance
  • Otherwise you can set the page size using thepair of switches
    Where w be the desired paper width and h be thedesired paper height in points (units of 1/72 of an inch).

Individual documents can (and often do) specify a paper size, which takesprecedence over the default size. To force a specific paper size andignore the paper size specified in the document, select a paper size asjust described, and also include the-dFIXEDMEDIA switch on thecommand line.

The default set of paper sizes will be included in the currentpagedevicein the InputAttributes dictionary with each paper size asone of the entries. The last entry in the dictionary (which has numeric keys)is a non-standard (Ghostscript extension) type of PageSize where the arrayhas four elements rather than the standard two elements. This four elementarray represents a page size range where the first two elements are the lowerbound of the range and the second two are the upper bound. By default theseare [0, 0] for the lower bound and [16#fffff, 16#fffff] for the upper bound.
The range type of PageSize is intended to allow flexible page size sepcificationfor non-printer file formats such as JPEG, PNG, TIFF, EPS, ...
For actual printers, either the entire InputAttributes dictionaryshould be replaced or the range type entry should not be included. To simplifyusing the default page sizes in the InputAttributes dictionary,the command line option -dNORANGEPAGESIZE can be used. Usingthis option will result in automatic rotation of the document page if the requestedpage size matches one of the default page sizes.

When the -dFIXEDMEDIA switch is given on thecommand line, the InputAttributes dictionary will only be populatedwith the single page size. This allows the -dPSFitPage option to fitthe page size requested in a PostScript file to be rotated, scaled and centeredfor the best fit on the specified page.

Changing the installed default paper size

You can change the installed default paper size on an installed version of Ghostscript, by editing the initialization file file is usually in the Resource/Init directory somewhere in the search path. See the section on finding files for details.

Find the line


Then to make A4 the default paper size, uncomment the line to changethis to


For a4 you can substitute anypaper size Ghostscript knows.

This supecedes the previous method of uncommenting the line% (a4) ....

Sometimes the initialization files are compiled into Ghostscript and cannot be changed.

On Windows and some Linux builds, the default paper size will beselected to be a4 or letter dependingon the locale.

Interacting with pipes

As noted above, input files are normally specified on the commandline. However, one can also "pipe" input into Ghostscript from anotherprogram by using the special file name '-' which is interpreted as standard input. Examples:

{some program producing ps} | gs [options] -
zcat | gs -

When Ghostscript finishes reading from the pipe, it quits rather thangoing into interactive mode. Because of this, options and files after the '-' in the command line will be ignored.

On Unix and MS Windows systems you can send output to a pipe in the same way. For example, to pipe the output to lpr, use the command

gs -q -sOutputFile=- | lpr

In this case you must also use the -qswitch to prevent Ghostscript from writing messages to standard outputwhich become mixed with the intended output stream.

Also, using the -sstdout=%stderr option is useful, particularly withinput from PostScript files that may print to stdout.

Similar results can be obtained with the %stdout and %pipe% filedevices. The example above would become

gs -sOutputFile=%stdout -q | lpr
gs -sOutputFile=%pipe%lpr
(again, doubling the % character on MS Windows systems.)

In the last case, -q isn't necessary since Ghostscript handles the pipe itself and messages sent to stdout will be printed as normal.

Using Ghostscript with PDF files

Ghostscript is normally built to interpret both PostScript and PDF files, examining each file to determine automatically whether its contents are PDF or PostScript. All the normal switches and procedures for interpreting PostScript files also apply to PDF files, with a few exceptions. In addition, thepdf2ps utility uses Ghostscript to convert PDF to (Level 2) PostScript.

Switches for PDF files

Here are some command line options specific to PDF

Begins interpreting on the designated page of the document.Pages of all documents in PDF collections are numbered sequentionally.
Stops interpreting after the designated page of the document.Pages of all documents in PDF collections are numbered sequentionally.
Rather than selecting a PageSize given by the PDF MediaBox, BleedBox (see -dUseBleedBox),TrimBox (see -dUseTrimBox), ArtBox (see -dUseArtBox), or CropBox (see -dUseCropBox),the PDF file will be scaled to fit the current device page size(usually the default page size).

This is useful for creating fixed size images of PDF files that may havea variety of page sizes, for example thumbnail images.

This option is also set by the -dFitPage option.

Determines whether the file should be displayed or printed using the"screen" or "printer" options for annotations and images. With-dPrinted, the output will use the file's "print"options; with -dPrinted=false, the output will use thefile's "screen" options. If neither of these is specified, the output willuse the screen options for any output device that doesn't have anOutputFile parameter, and the printer options fordevices that do have this parameter.
Sets the page size to the BleedBox rather than the MediaBox.defines the region to which the contents of the page should beclipped when output in a production environment. This may includeany extra bleed area needed to accommodate the physical limitationsof cutting, folding, and trimming equipment. The actual printed pagemay include printing marks that fall outside the bleed box.
Sets the page size to the TrimBox rather than the MediaBox.The trim box defines the intended dimensions of the finished pageafter trimming. Some files have a TrimBox that is smaller than theMediaBox and may include white space, registration or cutting marksoutside the CropBox. Using this option simulates appearance of thefinished printed page.
Sets the page size to the ArtBox rather than the MediaBox.The art box defines the extent of the page's meaningful content(including potential white space) as intended by the page's creator.The art box is likely to be the smallest box. It can be usefulwhen one wants to crop the page as much as possiblewithout losing the content.
Sets the page size to the CropBox rather than the MediaBox.Unlike the other "page boundary" boxes, CropBox does not have adefined meaning, it simply provides a rectangle to which thepage contents will be clipped (cropped). By convention, it isoften, but not exclusively, used to aid the positioning of contenton the (usually larger, in these cases) media.
Sets the user or owner password to be used in decoding encryptedPDF files. For files created with encryption method 4 or earlier, thepassword is an arbitrary string of bytes; with encryption method 5 orlater, it should be text in either UTF-8 or your locale's characterset (Ghostscript tries both).
Don't enumerate anntoations associated with the page objects throughAnnots attribute. Annotations are shown by default.
Show annotations referred from the Interactive Form Dictionary (AcroForm dictionary).By default, AcroForm is not enumerated because Adobe Acrobat doesn't do this.This option may be useful for debugging or recovery of incorrect PDF filesthat don't associate all annotations with the page objects.
Ignore UserUnit parameter. This may be useful for backwardcompatibility with old versions of Ghostscript and Adobe Acrobat,or for processing files with large values of UserUnitthat otherwise exceed implementation limits.
If a glyph is not present in a font the normal behaviour is to use the /.notdefglyph instead. On TrueType fonts, this is often a hollow sqaure. Under someconditions Acrobat does not do this, instead leaving a gap equivalent to thewidth of the missing glyph, or the width of the /.notdef glyph if no /Widthsarray is present. Ghostscript now attempts to mimic this undocumented featureusing a user parameter RenderTTNotdef. The PDF interpreter sets thisuser parameter to the value of RENDERTTNOTDEF in systemdict,when rendering PDF files. To restore rendering of /.notdef glyphs from TrueType fonts in PDF files, set this parameter to true.

Problems interpreting a PDF file

Occasionally you may try to read or print a 'PDF' file thatGhostscript doesn't recognize as PDF, even though the same filecan be opened and interpreted by an Adobe Acrobat viewer.In many cases, this is because of incorrectly generated PDF. Acrobattends to be very forgiving of invalid PDF files. Ghostscript tends toexpect files to conform to the standard. For example, even thoughvalid PDF files must begin with %PDF, Acrobat willscan the first 1000 bytes or so for this string, and ignore any precedinggarbage.

In the past, Ghostscript's policy has been to simply fail with anerror message when confronted with these files. This policy has, nodoubt, encouraged PDF generators to be more careful. However, we nowrecognize that this behavior is not very friendly for people who justwant to use Ghostscript to view or print PDF files. Our new policy isto try to render broken PDF's, and also to print a warning, so thatGhostscript is still useful as a sanity-check for invalid files.

PDF files from standard input

The PDF language, unlike the PostScript language, inherently requiresrandom access to the file.If you provide PDF to standard input using thespecial filename '-',Ghostscript will copy it to a temporary file before interpreting the PDF.

Using Ghostscript with EPS files

Encapsulated PostScript (EPS) files are intended to be incorporatedin other PostScript documents and may not display or print on theirown. An EPS file must conform to the Document Structuring Conventions,must include a %%BoundingBox line to indicate therectangle in which it will draw, must not use PostScript commandswhich will interfere with the document importing the EPS,and can have either zero pages or one page.Ghostscript has support for handling EPS files, but requiresthat the %%BoundingBox be in the header,not the trailer.To customize EPS handling, see EPS parameters.

For the official description of the EPS file format, pleaserefer to the Adobe documentation in their tech note #5002. Itis available from:

Using Ghostscript with overprinting and spot colors

In general with PostScript and PDF interpreters, the handling ofoverprinting and spot colors depends upon theprocess color model of the output device. Devicesthat produce gray or RGB output have an additive process color model.Devices which produce CMYK output have a subtractive process color model.Devices may, or may not, have support for spot colors.

Note: The differences in appearance of files with overprinting and spot colorscaused by the differences in the color model of the output device are part of thePostScript and PDF specifications. They are not due to a limitation in theimplementation of Ghostscript or its output devices.

With devices which use a subtractive process color model, both PostScriptand PDF allow the drawing of objects using colorants (inks) for one or more planeswithout affecting the data for the remaining colorants. Thus the inks for oneobject may overprint the inks for another object. In some casesthis produces a transparency like effect. (The effects of overprinting shouldnot be confused with the PDF 1.4 blending operations which are supported forall output devices.) Overprinting is not allowed for devices with an additiveprocess color model. With files that use overprinting, the appearance of theresulting image can differ between devices which produce RGB output versus deviceswhich produce CMYK output. Ghostscript automatically overprints (if needed)when the output device uses a subtractive process color model. For example,if the file is using overprinting, differences can be seen in the appearanceof the output from the tiff24nc and tiff32nc deviceswhich use an RGB and a CMYK process color models.

Most of the Ghostscript output devices do not havefile formats which support spot colors. Instead spot colors are converted usingthe tint transform function contained within the color space definition.. Howeverthere are several devices which have support for spot colors. The PSD format(Adobe Photoshop) produced by the psdcmyk devicecontains both the raster data plus an equivalent CMYK color for each spot color.This allows Photoshop to simulate the appearance of the spot colors. The displaydevice (MS Windows, OS/2, gtk+) can be used with different color models:Gray, RGB, CMYK only, or CMYK plus spot colors (separation). The display device,when using its CMYK plus spot color (separation) mode, also uses an equivalentCMYK color to simulate the appearance of the spot color. Thetiffsepdevice creates output files for each separation (CMYK and any spot colorspresent). It also creates a composite CMYK file using an equivalent CMYK colorto simulate the appearance of spot colors. Thexcfcmyk devicecreates output files with spot colors placed in separate alpha channels. (TheXCF file format does not currently directly support spot colors.)

Overprinting with spot colors is not allowed if the tint transform functionis being used to convert spot colors. Thus if spot colors are used with overprinting,then the appearance of the result can differ between output devices. One resultwould be obtained with a CMYK only device and another would be obtained witha CMYK plus spot color device. In a worst case situation where a file has overprintingwith both process (CMYK) and spot colors, it is possible to get three differentappearances for the same input file using thetiff24nc (RGB),tiff32nc (CMYK), andtiffsep (CMYK plus spot colors) devices.

In Adobe Acrobat, viewing of the effects of overprinting is enabled by the'Overprint Preview' item in the 'Advanced' menu. This feature is not availablein the free Acrobat Reader. The free Acrobat Reader also uses the tint transformfunctions to convert spot colors to the appropriate alternate color space.

How Ghostscript finds files

When looking for initialization files (gs_*.ps,pdf_*.ps), font files, the Fontmap file,files named on the command line, and resource files, Ghostscript first tests whether thefile name specifies an absolute path.

Testing a file name for an absolute path
System   Does the name ...

Unix   Begin with / ?
MS Windows   Have : as its second character, or begin with /, \, or //servername/share/ ?
VMS   Contain a node, device, or root specification?

If the test succeeds, Ghostscript tries to open the fileusing the name given. Otherwise it tries directories in this order:

  1. The current directory if enabled by the-P switch;
  2. The directories specified by -Iswitches in the command line, if any;
  3. The directories specified by the GS_LIBenvironment variable, if any;
  4. If built with COMPILE_INITS=1 (currently the default build) the files in the%rom%Resource/Init/ and %rom%lib/ file system builtinto the executable ;
  5. The directories specified by the GS_LIB_DEFAULT macro(if any) in the makefile when this executable was built.

GS_LIB_DEFAULT,GS_LIB, and the-I parameter may specify either a singledirectory or a list of directories separated by a character appropriate forthe operating system (":" on Unix systems,"," on VMS systems, and";" on MS Windows systems).By default, Ghostscript no longer searches the current directory firstbut provides -P switch for a degreeof backward compatibility.

Note that Ghostscript does not use this file searching algorithm for therun or file operators: for these operators, itsimply opens the file with the name given. To run a file using the searchingalgorithm, use runlibfile instead of run.

Finding PostScript Level 2 resources

Adobe specifies that resources are installed in a single directory.Ghostscript instead maintains a list of resource directories,and uses an extended method for finding resource files.

The search for a resource file depends on whetherthe value of the system parameter GenericResourceDirspecifies an absolute path. The user may set it as explained inResource-related parameters.

If the user doesn't set the system parameter GenericResourceDir,or use the -sGenericResourceDir= command line option, Ghostscriptcreates a default value for it by looking on the directory paths explained inHow Ghostscript finds files, excluding the current directory.The first path with Resource in it is used, including any prefixup to the path separator character following the string Resource.For example, when COMPILE_INITS=1 (the current default build), if the first pathis %rom%Resource/Init/, then the GenericResourceDirsystemparam will be set to %rom%Resource/ by default.

If the value of the system parameter GenericResourceDiris an absolute path (the default),Ghostscript assumes a single resource directory.It concatenates :

  1. The value of the system parameter GenericResourceDir;
  2. The name of the resource category (for instance, CMap);
  3. The name of the resource instance (for instance, Identity-H).

If the value of the system parameter GenericResourceDiris not an absolute path,Ghostscript assumes multiple resource directories.In this case it concatenates :

  1. A directory listed in the sectionHow Ghostscript finds files,except the current directory;
  2. The value of the system parameter GenericResourceDir;
  3. The name of the resource category (for instance, CMap);
  4. The name of the resource instance (for instance, Identity-H)
Due to possible variety of the part 1, the first successful combination is used.For example, if the value of the system parameter GenericResourceDiris the string ../Resource/(or its equivalent in the file path syntax of the underlying platform),Ghostscript searches for ../Resource/CMap/Identity-Hfrom all directories listed inHow Ghostscript finds files.So in this example, if the user on a Windows platform specifiesthe command line option -I.;../gs/lib;c:/gs8.50/lib,Ghostscript searches for ../gs/Resource/CMap/Identity-H andthen for c:/gs8.50/Resource/CMap/Identity-H.

To get a proper platform dependent syntax Ghostscript insertsthe value of the system parameterGenericResourcePathSep (initially"/" on Unix and Windows, ":" on MacOS,"." or "]" on OpenVMS).The string ../Resource is replaced with aplatform dependent equivalent.

In the case of multiple resource directories,the default ResourceFileName procedure retrieves either a pathto the first avaliable resource, or if the resource is not available itreturns a path starting with GenericResourceDir.Consequently Postscript installers of Postscript resourceswill overwrite an existing resource or add a new one to the first resource directory.

To look up fonts, after exhausting the search method described in thenext section, it concatenates together

  1. the value of the system parameterFontResourceDir (initially/Resource/Font/)
  2. the name of the resource font (for instance, Times-Roman)

Note that even although the system parameters are named "somethingDir", theyare not just plain directory names: they have "/" on theend, so that they can be concatenated with the category name or font name.

Font lookup

Ghostscript has a slightly different way to find the file containing a fontwith a given name. This rule uses not only the search path defined by-I, GS_LIB, andGS_LIB_DEFAULT as describedabove, but also the directory that is the value of theFontResourceDir system parameter, and an additional list ofdirectories that is the value of the GS_FONTPATH environmentvariable (or the value provided with the -sFONTPATH= switch,if present).

At startup time, Ghostscript reads in the Fontmap files inevery directory on the search path (or in the list provided with the-sFONTMAP= switch, if present): these files are catalogs offonts and the files that contain them. (See thedocumentation of fonts for details.) Then, when Ghostscript needs tofind a font that isn't already loaded into memory, it goes through a seriesof steps.

  • First, it looks up the font name in the combined Fontmaps. If there is anentry for the desired font name, and the file named in the entry can befound in some directory on the general search path (defined by-I, GS_LIB, andGS_LIB_DEFAULT), and the file is loaded successfully, andloading it defines a font of the desired name, that is the end of theprocess.
  • If this process fails at any step, Ghostscript looks for a file whose nameis the concatenation of the value of the FontResourceDirsystem parameter and the font name, with no extension. If such a fileexists, can be loaded, and defines a font of the desired name, that again isthe end. The value of FontResourceDir is normally thestring /Resource/Font/, but it can be changed with thesetsystemparams operator: see the PostScript LanguageReference Manual for details.
  • If that fails, Ghostscript then looks for a file on the general search pathwhose name is the desired font name, with no extension. If such a fileexists, can be loaded, and defines a font of the desired name, that again isthe end.
  • If that too fails, Ghostscript looks at the GS_FONTPATHenvironment variable (or the value provided with the-sFONTPATH= switch, if present), which is also a list ofdirectories. It goes to the first directory on the list, looking for allfiles that appear to contain PostScript fonts; it then adds all those filesand fonts to the combined Fontmaps, and starts over.
  • If scanning the first FONTPATH directory doesn't produce a file thatprovides the desired font, it adds the next directory on the FONTPATH list,and so on until either the font is defined successfully or the list isexhausted.
  • Finally, if all else fails, it will try to find a substitute for the fontfrom among the standard 35 fonts.

CID fonts (e.g. Chinese, Japanese and Korean)are found using a different method.

Differences between search path and font path
Search path   Font path

-I switch   -sFONTPATH= switch
GS_LIB and GS_LIB_DEFAULT environment variables   GS_FONTPATH environment variable
Consulted first   Consulted only if search path and FontResourceDir don't provide the file.
Font-name-to-file-name mapping given in Fontmap files; aliases are possible, and there need not be any relation between the font name in the Fontmap and the FontName in the file.   Font-name-to-file-name mapping is implicit -- the FontName in the file is used. Aliases are not possible.
Only fonts and files named in Fontmap are used.   Every Type 1 font file in each directory is available; if TrueType fonts are supported (the feature was included when the executable was built), they are also available.

If you are using one of the following types of computer, you may wish toset the environment variable GS_FONTPATH tothe value indicated so that Ghostscript will automatically acquire all theinstalled Type 1 (and, if supported, TrueType) fonts (but see below fornotes on systems marked with "*"):

Suggested GS_FONTPATH for different systems
    System type   GS_FONTPATH

    Digital Unix   /usr/lib/X11/fonts/Type1Adobe
    Ultrix   /usr/lib/DPS/outline/decwin
    HP-UX 9   /usr/lib/X11/fonts/
    IBM AIX   /usr/lpp/DPS/fonts/outlines
    NeXT   /NextLibrary/Fonts/outline
*   SGI IRIX   /usr/lib/DPS/outline/base
    SunOS 4.x
(NeWSprint only)
**   SunOS 4.x   /usr/openwin/lib/X11/fonts/Type1/outline
**   Solaris 2.x   /usr/openwin/lib/X11/fonts/Type1/outline

* On SGI IRIX systems, you must use Fontmap.SGI inplace of Fontmap or Fontmap.GS, becauseotherwise the entries in Fontmap will take precedence overthe fonts in the FONTPATH directories.

** On Solaris systems simply setting GS_FONTPATH orusing -sFONTPATH= may not work, because for some reason someversions of Ghostscript can't seem to find any of the Type1 fonts in/usr/openwin/lib/X11/fonts/Type1/outline. (It says: "15files, 15 scanned, 0 new fonts". We think this problem has been fixed inGhostscript version 6.0, but we aren't sure because we've never been able toreproduce it.) See Fontmap.Sol instead. Also, on Solaris2.x it's probably not worth your while to add Sun's fonts to your font pathand Fontmap. The fonts Sun distributes on Solaris 2.x in the directories


are already represented among the ones distributed as part of Ghostscript;and on some test files, Sun's fonts have been shown to cause incorrectdisplays with Ghostscript.

These paths may not be exactly right for your installation; if the indicateddirectory doesn't contain files whose names are familiar font names likeCourier and Helvetica, you may wish to ask your system administrator whereto find these fonts.

Adobe Acrobat comes with a set of fourteen Type 1 fonts, on Unix typicallyin a directory called .../Acrobat3/Fonts. There is noparticular reason to use these instead of the corresponding fonts in theGhostscript distribution (which are of just as good quality), except to saveabout a megabyte of disk space, but the installation documentation explainshow to do it on Unix.

CID fonts

CID fonts are PostScript resources containing alarge number of glyphs (e.g. glyphs for Far East languages,Chinese, Japanese and Korean).Please refer to the PostScript Language Reference,third edition, for details.

CID font resources are a different kind of PostScript resource from fonts.In particular, they cannot be used as regular fonts.CID font resources must first be combined with a CMap resource, whichdefines specific codes for glyphs, before it can be used as a font. Thisallows the reuse of a collection of glyphs with different encodings.

The simplest method to request a font composed of a CID font resourceand a CMap resource in a PostScript document is

/CIDFont-CMap findfont
where CIDFont is a name of anyCID font resource, and CMap is a name of a CMap resourcedesigned for the same character collection. The interpreter will composethe font automatically from the specified CID font and CMap resources.Another method is possible using the composefont operator.

CID fonts must be placed in the /Resource/CIDFont/ directory.They are not found using Font lookupon the search path or font path.

CID font substitution

Automatic CIDFont Substitution

In general, it is highly recommended that CIDFonts used in the creation of PDFjobs should be embedded or available to Ghostscript as CIDFont resources, thisensures that the character set, and typeface style are as intended by theauthor.

In cases where the original CIDFont is not available, the next best option isto provide Ghostscript with a mapping to a suitable alternative CIDFont - seebelow for details on how this is achieved. However, Ghostscript does provide theability to use a "fall back" CIDFont substitute. As shipped, this uses theDroidSansFallback.ttf font. This font contains a large number of glyphs coveringseveral languages, but it is not comprehensive. There is, therefore, a chancethat glyphs may be wrong, or missing in the output when this fallback is used.

Internally, the font is referenced as CIDFont resource called CIDFallBack, thusa different fallback from DroidSansFallback.ttf can be specified adding amapping to your cidfmap file (see below for details) to map the name "CIDFallBack"as you prefer. For CIDFallBack the mapping must be a TrueTypefont or TrueType collection, it cannot be a Postscript CIDFont file.

As with any font containing large numbers of glyphs, DroidSansFallback.ttf isquite large (~3.5Mb at the of writing). If this is space you cannot afford inyour use of Ghostscript, you can simply delete the file from:Resource/CIDFSubst/DroidSansFallback.ttf. The build system will cope with thefile being removed, and the initialization code will avoid adding the internalfall back mapping if the file is missing.

If DroidSansFallback.ttf is removed, and no other CIDFallBack mapping is supplied,the final "fall back" is to use a "dumb" bullet CIDFont, called ArtifexBullet. Asthe name suggests, this will result in all the glyphs from a missing CIDFont being replaced witha simple bullet point.

This type of generic fall back CIDFont substitution can be very useful forviewing and proofing jobs, but may not be appropriate for a "production"workflow, where it is expected that only the original font should beused. For this situation, you can supply Ghostscript with the command line option:-dPDFNOCIDFALLBACK. By combining -dPDFNOCIDFALLBACK with -dPDFSTOPONERRORa production workflow can force a PDF with missing CIDFonts to error, and avoidrealising a CIDFont was missing only after printing.

The directory in which the fallback TrueType font or collection can be specified by thecommand line parameter -sCIDFSubstPath="path/to/TTF", or with the environmentvariable CIDFSUBSTPATH. The file name of the substitute TrueType font can bespecified using the command line parameter -sCIDFSubstFont="TTF file name" orthe environment variable CIDFSUBSTFONT.

Explicit CIDFont Substitution

Substitution of CID font resources is controlled by the Ghostscriptconfiguration file lib/cidfmap, which defines a CID font resource map.

The file forms a table of records, each of which should use one of three formats,explained below. Users may modify Resource/Init/cidfmap to configureGhostscript for a specific need. Note that the default Ghostscript build includessuch configuration and resource files in a rom file system built into the executable.So, to ensure your changes have an effect, you should do one of the following: rebuildthe executable; use the "-I" command line option to add the directory containing yourmodified file to Ghostscript's search path; or, finally, build Ghostscript to use diskbased resources.

Format 1

To substitute a CID font resource with another CID font resource, add a record like this :

/Substituted /Original ;
where Substituted is a name of CID font resource being usedby a document, and Original is a name of an availableCID font resource. Please pay attention that both them must bedesigned for same character collection. In other words, youcannot substitute a Japanese CID font resource with a Korean CID font resource,etc. CMap resource names must not appear inlib/cidfmap. The trailing semicolon and the space before itare both required.

Format 2

To substitute (emulate) a CID font resource with a TrueType font file, add a record like this :

/Substituted << keys&values >> ;
Where keys&values are explained in the table below.
Key Type Description
/Path string A path to a TrueType font file. This must be an absolute path. If using -dSAFER, the directory containing the font file must be on one of the permitted paths.
/FileType name Must be /TrueType.
/SubfontID integer (optional) Index of the font in font collection, such as TTC. This is ignored if Path doesn't specify a collection. The first font in a collection is 0. Default value is 0.
/CSI array of 2 or 3 elements (required) Information for building CIDSystemInfo.

If the array consists of 2 elements, the first element is a string, which specifies Ordering; the second element is a number, which specifies Supplement.

If the array consists of 3 elements, the first element is a string, which specifies Registry; the second element is a string, which specifies Ordering; the third element is a number, which specifies Supplement.

Currently only CIDFontType 2 can be emulated with a TrueType font.The TrueType font must contain enough characters to cover anAdobe character collection, which is specified in Ordering and used in documents.

Format 3

To point Ghostscript at a specific CIDFont file outside it's "normal" resource search path :

/CIDName (path/to/cid/font/file) ;
where CIDName is a name of CID font resource being usedby a document, and "path/to/cid/font/file" is the path to thePostscript CIDFont file, including the file name. NOTE: the CIDFont file, whenexecuted by the Postscript interpreter, must result in a CIDFont resource beingdefined whose CIDFontName matches the "CIDName" key for the current record.I.E. an entry with the key /PingHei-Bold must reference a file which creates aCIDFont resource called "PingHei-Bold". To substitute a file based CIDFont fora differently named CIDFont, use formats 1 and 3 in combination (the order of theentries is not important).The trailing semicolon and the space before it are both required.

NOTE: Environment Variables

It is also possible to influence the path using standard, or your own environment variables, usingthe custom Postscript operator getenv. Said operator takes a string parameter on the stackwhich is the environment variable to interrogate, and returns either a string, containing the value ofthe environment variable, and boolean true to indicate success, or just a booleanfalse to indicate failure. See below for an example of its use.

Examples :

Format 1:
/Ryumin-Medium /ShinGo-Bold ;
/Ryumin-Light /MS-Mincho ;
Format 2:
/Batang << /FileType /TrueType /Path (C:/WINDOWS/fonts/batang.ttc) /SubfontID 0 /CSI [(Korea1) 3] >> ;
/Gulim << /FileType /TrueType /Path (C:/WINDOWS/fonts/gulim.ttc) /SubfontID 0 /CSI [(Korea1) 3] >> ;
/Dotum << /FileType /TrueType /Path (C:/WINDOWS/fonts/gulim.ttc) /SubfontID 2 /CSI [(Korea1) 3] >> ;

Format 2 & environment variable:
/SimHei << /FileType /TrueType /Path (windir) getenv not {(c:/windows)}if (/fonts/simhei.ttf) concatstrings /SubfontID 0 /CSI [(GB1) 2] >> ;
Format 1 & 2
/SimSun << /FileType /TrueType /Path (C:/WINDOWS/fonts/simsun.ttc) /SubfontID 0 /CSI [(GB1) 2] >> ;
/SimHei << /FileType /TrueType /Path (C:/WINDOWS/fonts/simhei.ttf) /SubfontID 0 /CSI [(GB1) 2] >> ;
/STSong-Light /SimSun ;
/STHeiti-Regular /SimHei ;
Format 3:
/PMingLiU (/usr/local/share/font/cidfont/PMingLiU.cid) ;
Format 1 & 3
/Ryumin-Light /PMingLiU ;
/PMingLiU (/usr/local/share/font/cidfont/PMingLiU.cid) ;

The win32 installer of recent version of ghostscript has a checkbox for"Use Windows TrueType fonts for Chinese, Japanese and Korean" to optionally updatelib/cidfmap with the common CJK fonts provided by Microsoft products. The scriptcan also be run separately (e.g. against a network drive with windows CJK fonts):

gswin32c -q -dBATCH -sFONTDIR=c:/windows/fonts -sCIDFMAP=lib/cidfmap lib/

Note that the font file path uses Postscript syntax.Because of this, backslashes in the paths must berepresented as a double backslash.

This can complicate substitutions for fonts with non-Roman names.For example, if a PDF file asks for a font with the name/#82l#82r#83S#83V#83b#83N. This cannot be used directlyin a cidfmap file because the #xx notation in names is a PDF-onlyencoding. Instead, try something like:

<82C68272835383568362834E>cvn << /Path(C:/WINDOWS/Fonts/msmincho.ttc) /FileType /TrueType /SubfontID 0 /CSI[(Japan1) 3] >> ;
Where <82C68272835383568362834E> is the same bytesequence converted to a hex string. This lets you specify a nameusing any sequence of bytes through the encodings available forPostscript strings.

Note that loading truetype fonts directly from/Resources/CIDFont is no longer supported.There is no reliable way to generate a character ordering for truetypefonts. The 7.0x versions of Ghostscript supported this by assuming a Japanesecharacter ordering. This is replaced in the 8.0x and later releases withthe more general cidfmap mechanism.

The PDF specification requires CID font files to be embedded,however some documents omit them. As a workaroundthe PDF interpreter applies an additional substitution method whena requested CID font resource is not embedded and it is not available.It takes values of the keys Registry and Orderingfrom the CIDFontSystem dictionary,and concatenates them with a dash inserted.For example, if a PDF CID font resource specifies

/CIDSystemInfo << /Registry (Adobe) /Ordering (CNS1) /Supplement 1 >>
the generated subsitituite name is Adobe-CNS1.The latter may look some confusing for a font name,but we keep it for compatibility with older Ghostscript versions,which do so due to a historical reason.Add a proper record to lib/cidfmap to provide it.

Please note that when a PDF font resource specifies

/Registry (Adobe) /Ordering (Identity)
there is no way to determine the language properly.If the CID font file is not embedded, the Adobe-Identityrecord depends on the document and a correct record isn't possible whena document refers to multiple Far East languages.In the latter case add individual records for specific CID font names used in the document.

Consequently, if you want to handle any PDF document withnon-embedded CID fonts (which isn't a correct PDF),you need to create a suitable lib/cidfmap by hand,possibly a specific one for each document.

Using Unicode True Type fonts

Ghostscript can handle True Type fonts with the full Unicode character set.For doing that, a third-party software should generate a Postscriptor PDF document with a text, which is encoded with theUTF-16 encoding. Ghostscript may be used for convertingsuch Postscript documents to PDF and forre-distilling such PDF documents to PDF subsets.

To render an UTF-16 encoded text, one must do the following :

  • Provide a True Type font with Unicode Encoding.It must have a cmap table withplatformID equals to 3 (Windows),and SpecificID eqials to 1 (Unicode).
  • Describe the font in lib/cidfmapwith special values for the CSI key :[(Artifex) (Unicode) 0].
  • In the PS or PDF document combine the fontwith one of CMap Identity-UTF16-H(for the horizontal writing mode)or Identity-UTF16-V(for the vertical writing mode).Those CMaps are distributed with Ghostscriptin Resource/CMap.
Please note that /Registry (Adobe) /Ordering (Identity)won't properly work for Unicode documents,especially for the searchability feature(see CID font substitution).

Temporary files

Where Ghostscript puts temporary files
Platform   Filename   Location

MS Windows and OpenVMS   _temp_XX.XXX   Current directory
OS/2   gsXXXXXX   Current directory
Unix   gs_XXXXX   /tmp

You can change in which directory Ghostscript creates temporary files bysetting the TMPDIR or TEMP environmentvariable to the name of the directory you want used. Ghostscript currentlydoesn't do a very good job of deleting temporary files if it exits becauseof an error; you may have to delete them manually from time to time.

Notes on specific platforms


The Ghostscript distribution includes some Unix shell scripts to use withGhostscript in different environments. These are all user-contributedcode, so if you have questions, please contact the user identified in thefile, not Artifex Software.
Preview a specified page of a dvi file in an X window
System V 3.2 lp interface for parallel printer
Printing on an H-P PaintJet under HP-UX
Queue filter for lpr under Unix;its documentation is intended for systemadministrators
Setup for


  • To be able to specify switches and file names when invoking theinterpreter, define gs as a foreign command:
    $ gs == "$disk:[directory]gs.exe"

    where the "disk" and "directory" specify wherethe Ghostscript executable is located. For instance,

    $ gs == "$dua1:[ghostscript]gs.exe"
  • On VMS systems, the last character of each "directory" name indicateswhat sort of entity the "directory" refers to. If the "directory" nameends with a colon ":", it is taken to refer to a logicaldevice, for instance
    $ define ghostscript_device dua1:[ghostscript_510]
    $ define gs_lib ghostscript_device:

    If the "directory" name ends with a closing square bracket"]", it is taken to refer to a real directory, for instance

    $ define gs_lib dua1:[ghostscript]
  • Defining the logical GS_LIB
    $ define gs_lib disk:[directory]

    allows Ghostscript to find its initialization files in the Ghostscriptdirectory even if that's not where the executable resides.

  • Although VMS DCL itself converts unquoted parameters to upper case, Cprograms such as Ghostscript receive their parameters through the C runtimelibrary, which forces all unquoted command-line parameters to lower case.That is, with the command
    $ gs -Isys$login:

    Ghostscript sees the switch as -isys$login,which doesn't work. To preserve the case of switches, quote them likethis:

    $ gs "-Isys$login:"
  • If you write printer output to a file with-sOutputFile= and then want to print the file later, use"PRINT/PASSALL".
  • PDF files (or PostScript files that use thesetfileposition operator) must be "stream LF" type files towork properly on VMS systems. (Note: This definitely mattersif Ghostscript was compiled with DEC C; we are not sure of the situation ifyou use gcc.) Because of this, if you transfer files byFTP, you probably need to do one of these two things after the transfer:
    1. If the FTP transfer was in text (ASCII) mode:
      $ convert/fdl=streamlf.fdl input-file output-file

      where the contents of the file STREAMLF.FDL are

              ORGANIZATION            sequential
              BLOCK_SPAN              yes
              CARRIAGE_CONTROL        carriage_return
              FORMAT                  stream_lf
    2. If the FTP transfer was in binary mode:
      $ set file/attribute=(rfm:stmlf)

Using X Windows on VMS

If you are using on an X Windows display, you can set it up with the nodename and network transport, for instance

$ set display/create/node=""/transport=tcpip

and then run Ghostscript by typing gs at the command line.

MS Windows

The name of the Ghostscript command line executable on MS Windows isgswin32c so use this instead of the plain 'gs' inthe quickstart examples.

To run the batch files in the ghostscript lib directory,you must add gs\bin andgs\lib to the PATH, wheregs is the top-level Ghostscript directory.

When passing options to ghostcript through a batch file wrapper such asps2pdf.bat you need to substitute '#' for '=' as the separatorbetween options and their arguments. For example:

ps2pdf -sPAPERSIZE#a4 file.pdf
Ghostscript treats '#' the same internally, and the '=' is mangled bythe command shell.

There is also an older version for MS Windows called just gswin32that provides its own window for the interactive postscript prompt.The executable gswin32c is usually the better option sinceit uses the native command prompt window.

For printer devices, the default output is the default printer.This can be modified as follows.

-sOutputFile="%printer%printer name"
Output to the named printer. If your printer is named "HP DeskJet 500"then you would use -sOutputFile="%printer%HP DeskJet 500".


Note: Ghostscript is no longer supported on MS-DOS.

Invoking Ghostscript from the command prompt in Windows is supported bythe Windows executable described above.

X Windows

Ghostscript looks for the following resources under the program nameghostscript and class nameGhostscript; the ones marked "**" arecalculated from display metrics:

X Windows resources
Name   Class   Default

background   Background   white
foreground   Foreground   black
borderColor   BorderColor   black
borderWidth   BorderWidth   1
geometry   Geometry   NULL
xResolution   Resolution   **
yResolution   Resolution   **
useExternalFonts   UseExternalFonts   true
useScalableFonts   UseScalableFonts   true
logExternalFonts   LogExternalFonts   false
externalFontTolerance   ExternalFontTolerance   10.0
palette   Palette   Color
maxGrayRamp   MaxGrayRamp   128
maxRGBRamp   MaxRGBRamp   5
maxDynamicColors   MaxDynamicColors   256
useBackingPixmap   UseBackingPixmap   true
useXPutImage   UseXPutImage   true
useXSetTile   UseXSetTile   true
regularFonts   RegularFonts   See "X fonts"
symbolFonts   SymbolFonts   See "X fonts"
dingbatFonts   DingbatFonts   See "X fonts"

X resources

  • To set X resources, put them in a file (such as~/.Xdefaults on Unix) in a form like this:
    Ghostscript*geometry:    595x842-0+0
    Ghostscript*xResolution:   72
    Ghostscript*yResolution:   72

    Then merge these resources into the X server's resource database:

    xrdb -merge ~/.Xdefaults
  • Ghostscript doesn't look at the default system background and foregroundcolors; if you want to change the background or foreground color, you mustset them explicitly for Ghostscript. This is a deliberate choice, so thatPostScript documents will display correctly by default -- with white aswhite and black as black -- even if text windows use other colors.
  • The geometry resource affects only window placement.
  • Resolution is expressed in pixels per inch (1 inch = 25.4mm).
  • The font tolerance gives the largest acceptable difference in height of thescreen font, expressed as a percentage of the height of the desired font.
  • The palette resource can be used to restrict Ghostscript tousing a grayscale or monochrome palette.
  • maxRGBRamp andmaxGrayRamp control the maximum number ofcolors that ghostscript allocates ahead of time for the dither cube (ramp).Ghostscript never preallocates more than half the cells in a colormap.maxDynamicColors controls the maximumnumber of colors that Ghostscript will allocate dynamically in thecolormap.

Working around bugs in X servers

The "use..." resources exist primarily to work around bugsin X servers.

  • Old versions of DEC's X server (DECwindows) have bugs that require setting useXPutImage or useXSetTile to false.
  • Some servers do not implement backing pixmaps properly, or do not have enough memory for them. If you get strange behavior or "out of memory" messages, try setting useBackingPixmap to false.
  • Some servers do not implement tiling properly. This appears as broad bands of color where dither patterns should appear. If this happens, try setting useXSetTile to false.
  • Some servers do not implement bitmap or pixmap displaying properly. This may appear as white or black rectangles where characters should appear; or characters may appear in "inverse video" (for instance, white on a black rectangle rather than black on white). If this happens, try setting useXPutImage to false.

X fonts

To use native X11 fonts, Ghostscript must map PostScript font names to theXLFD font names. The resources regularFonts(fonts available in standard or ISO-Latin-1 encoding),symbolFonts (using Symbol encoding), anddingbatFonts (using Dingbat encoding) givethe name mapping for different encodings. The XLFD font name in themapping must contain 7 dashes; the X driver adds the additional size andencoding fields to bring the total number of dashes in the font name to 14.See the appendix "X default font mappings"for the full list of default mappings.

Users who switch regularly between different X servers may wish to use the"*" wild card in place of the foundry name(itc,monotype,linotype,b&h, oradobe); users who do not switch X serversshould leave the explicit foundry in the name, since it speeds up access tofonts.

Ghostscript takes advantage of the "HP XLFD Enhancements," if available, touse native X11 fonts for fonts that are anamorphically scaled, rotated, ormirrored. If the changes have been installed to the X or font server, theyare automatically used when appropriate.

Using Ghostscript fonts on X displays

Font files distributed with Ghostscript can be used on X Windows displays.You can find full instructions in thedocumentation on fonts.

X device parameters

In addition to the device parameters recognized by all devices, Ghostscript's Xdriver provides parameters to adjust its performance. Users will rarelyneed to modify these. Note that these are parameters to be set with the-d switch in the command line (e.g.,-dMaxBitmap=10000000), not resources to be defined in the~/.Xdefaults file.

AlwaysUpdate <boolean>
If true, the driver updates the screen after eachprimitive drawing operation; if false (the default), thedriver uses an intelligent buffered updating algorithm.
MaxBitmap <integer>
If the amount of memory required to hold the pixmap for the window is nomore than the value of MaxBitmap, the driver will draw to apixmap in Ghostscript's address space (called a "client-side pixmap") andwill copy it to the screen from time to time; if the amount of memoryrequired for the pixmap exceeds the value of MaxBitmap, thedriver will draw to a server pixmap. Using a client-side pixmap usuallyprovides better performance -- for bitmap images, possibly much betterperformance -- but since it may require quite a lot of RAM (e.g., about 2.2Mb for a 24-bit 1024x768 window), the default value ofMaxBitmap is 0.
MaxTempPixmap, MaxTempImage <integer>
These control various aspects of the driver's buffering behavior. Fordetails, please consult the source file gdevx.h.

SCO Unix

Because of bugs in the SCO Unix kernel, Ghostscript will not work if youselect direct screen output and also allow it to write messages on theconsole. If you are using direct screen output, redirect Ghostscript'sterminal output to a file.

Command line options

Unless otherwise noted, these switches can be used on all platforms.

General switches

Input control

Causes Ghostscript to read filename and treat its contents thesame as the command line. (This was intended primarily for getting aroundDOS's 128-character limit on the length of a command line.) Switches orfile names in the file may be separated by any amount of white space(space, tab, line break); there is no limit on the size of the file.
-- filename arg1 ...
-+ filename arg1 ...
Takes the next argument as a file name as usual, but takes allremaining arguments (even if they have the syntactic form of switches) anddefines the name ARGUMENTS in userdict (not systemdict) asan array of those strings, before running the file. WhenGhostscript finishes executing the file, it exits back to the shell.
-@ filename arg1 ...
Does the same thing as -- and -+, butexpands @filename arguments.
These are not really switches: they tell Ghostscript to read fromstandard input, which is coming from a file or a pipe,with or without buffering.On some systems, Ghostscript may read the input one character at a time,which is useful for programs such as ghostview that generate input forGhostscript dynamically and watch for some response, but can slow processing.If performance is significantly slower than with a named file,try '-_' which always reads the input in blocks.However, '-' is equivalent on most systems.
-c token ...
-c string ...
Interprets arguments as PostScript code up to the next argument thatbegins with "-" followed by a non-digit, or with"@". For example, if the file quit.pscontains just the word "quit", then-c quit on the command line is equivalent there. Each argument must be valid PostScript,either individual tokens as defined by the token operator,or a string containing valid PostScript.
Interprets following non-switch arguments as file names to be executedusing the normal run command. Since this is the defaultbehavior, -f is useful only for terminating the list oftokens for the -c switch.
Execute the given file, even if its name begins with a"-" or "@".

File searching

Note that by "library files" here we mean all the files identified usingthe search rule under "How Ghostscript findsfiles" above: Ghostscript's own initialization files, fonts, and filesnamed on the command line.

-I directories
Adds the designated list of directories at the head of the search pathfor library files.
Makes Ghostscript look first in the current directory for libraryfiles.
Makes Ghostscript not look first in the currentdirectory for library files (unless, of course, the first explicitlysupplied directory is "."). This is now the default.

Setting parameters

Define a name in systemdict with value=true.
Define a name in systemdict with the given value. The value must bea valid PostScript token (as defined by the token operator).If the token is a non-literal name, it must be true, false, or null.It is recommeded that this is used only for simple values -- use-c (above) for complex values such as procedures,arrays or dictionaries.
Note that these values are defined before other names insystemdict, so any name that that conflicts with one usually insystemdict will be replaced by the normal definition during theinterpreter initialization.
Define a name in systemdict with a given string as value. This isdifferent from -d. For example, -dXYZ=35on the command line is equivalent to the program fragment
/XYZ 35 def

whereas -sXYZ=35 is equivalent to

/XYZ (35) def
Un-define a name, cancelling -d or -s.

Note that the initialization file makessystemdict read-only, so the values of names defined with-D, -d, -S, and-s cannot be changed -- although, of course, they can besuperseded by definitions in userdict or other dictionaries.However, device parameters set this way (PageSize,Margins, etc.) are not read-only, and canbe changed by code in PostScript files.

Equivalent to -dDEVICEWIDTH=number1 and-dDEVICEHEIGHT=number2, specifying the devicewidth and height in pixels for the benefit of devices such as X11 windowsand VESA displays that require (or allow) you to specify width and height.Note that this causes documents of other sizes to be clipped, not scaled:see -dFIXEDMEDIA below.
-rnumber (sameas -rnumberxnumber)
Equivalent to -dDEVICEXRESOLUTION=number1 and-dDEVICEYRESOLUTION=number2, specifying the devicehorizontal and vertical resolution in pixels per inch for the benefit ofdevices such as printers that support multiple X and Y resolutions.

Suppress messages

Quiet startup: suppress normal startup messages, and also do theequivalent of -dQUIET.

Parameter switches (-d and -s)

As noted above, -d and -s define initialvalues for PostScript names. Some of these names are parameters thatcontrol the interpreter or the graphics engine. You can also use-d or -s to define a value for any deviceparameter of the initial device (the one defined with-sDEVICE=, or the default device if this switch is notused). For example, since the ppmraw device has a numericGrayValues parameter that controls the number of bits percomponent, -sDEVICE=ppmraw -dGrayValues=16 will make thisthe default device and set the number of bits per component to 4 (log2(16)).

Rendering parameters

On high-resolution devices (at least 150 dpi resolution, or-dDITHERPPI specified), -dCOLORSCREENforces the use of separate halftone screens with different angles for CMYKor RGB if halftones are needed (this produces the best-quality output);-dCOLORSCREEN=0 uses separate screens with the samefrequency and angle; -dCOLORSCREEN=false forces the use ofa single binary screen. The default if COLORSCREEN is notspecified is to use separate screens with different angles if the devicehas fewer than 5 bits per color, and a single binary screen (which is neveractually used under normal circumstances) on all other devices.
Forces all devices to be considered high-resolution, and forces use ofa halftone screen or screens with lpi lines per inch, disregardingthe actual device resolution. Reasonable values for lpi areN/5 to N/20, where N is theresolution in dots per inch.
Turns on image interpolation for all images, improving image quality forscaled images at the expense of speed. Note that-dNOINTERPOLATE overrides -dDOINTERPOLATE ifboth are specified.

-dNOINTERPOLATE does nearest neighbour scaling(Bresenham's line algorithm through the image, plotting the closesttexture coord at each pixel). If we are downscaling this resultsin some source pixels not appearing at all in the destination. Ifwe are upscaling, at least some source pixels cover more than onedestination pixel.

In all but special cases -dDOINTERPOLATE uses a Mitchellfilter function to scale the contributions for each output pixel;upscaling, every output pixel ends up being the weighted sum of 16input pixels, downscaling more. Every source pixel has an effecton the output pixels.

Computationally, -dDOINTERPOLATE is much heavier workthan -dNOINTERPOLATE (lots of floating pointmuliplies and adds for every output pixel vs simple integer additions,subtractions, and shifts).

The exact algorithm used is from Graphics Gems 3, Chapter I.2 GeneralFiltered Image Rescaling.

These options control the use of subsample antialiasing. Their use is highly recommended for producing high quality rasterizations. The subsampling box size n should be 4 for optimum output, but smaller values can be used for faster rendering. Antialiasing is enabled separately for text and graphics content.Allowed values are 1, 2 or 4.

Note that because of the way antialiasing blends the edges of shapes into the background whenthey are drawn some files that rely on joining separate filled polygons together to coveran area may not render as expected with GraphicsAlphaBits at 2 or 4. If you encounterstrange lines within solid areas, try rendering that file again with-dGraphicsAlphaBits=1.

Chooses glyph alignent to integral pixel boundaries (if set to the value 1)or to subpixels (value 0). Subpixels are a smaller raster gridwhich is used internally for text antialiasing.The number of subpixels in a pixel usually is 2^TextAlphaBits,but this may be automatically reduced for big characters to save spacein character cache.

The parameter has no effect if -dTextAlphaBits=1.Default value is 0.

Setting -dAlignToPixels=0 can improve renderingof poorly hinted fonts, but may impair the appearance of well-hinted fonts.

This specifies the initial value for the implementation specificuser parameter GridFitTT.It controls grid fitting of True Type fonts(Sometimes referred to as "hinting", but strictly speakingthe latter is a feature of Type 1 fonts).Setting this to 2 enables automatic grid fitting for True Type glyphs.The value 0 disables grid fitting. The default value is 2.For more information see the description of the user parameterGridFitTT.
Set UseCIEColor in the page device dictionary, remapping device-dependentcolor values through a Postscript defined CIE color space. Document DeviceGray,DeviceRGB and DeviceCMYK source colors will be substituted respectively by PostscriptCIEA, CIEABC and CIEDEFG color spaces. See the documentGS9 Color Management for details on howthis option will interact with Ghostscript's ICC-based color workflow. If accurate colorsare desired, it is recommended that an ICC workflow be used.
Substitutes DeviceGray for CIEBasedA, DeviceRGB for CIEBasedABC and CIEBasedDEF spaces and DeviceCMYKfpr CIEBasedDEFG color spaces. Useful only onvery slow systems where color accuracy is less important.
This switch prevents the substitution of the ColorSpaceresources (DefaultGray, DefaultRGB, andDefaultCMYK) for the DeviceGray,DeviceRGB, and DeviceCMYK color spaces.This switch is primarily useful for PDF creation using the pdfwritedevice when retaining the color spaces from the original document isimportant.
Disables the automatic loading and use of an input color space that iscontained in a PostScript file as DSC comments starting with the %%BeginICCProfile:comment. ICC profiles are sometimes embedded by applications to convey the exactinput color space allowing better color fidelity. Since the embedded ICC profilesoften use multidimensional RenderTables, color conversion may be slower than usingthe Default color conversion invoked when the -dUseCIEColoroption is specified, therefore the -dNOPSICC option may resultin improved performance at slightly reduced color fidelity.
Turns off image interpolation, improving performance on interpolatedimages at the expense of image quality. -dNOINTERPOLATEoverrides -dDOINTERPOLATE.
Turns off PDF 1.4 transparency, resulting in faster (but possiblyincorrect) rendering of pages containing PDF 1.4 transparency andblending.
Turns off the TN 5044 psuedo operators. These psuedo operators are not a partof the official Postscript specification. However they are defined in TechnicalNote #5044 Color Separation Conventions for PostScript Language Programs.These psuedo operators are required for some files from QuarkXPress. However somefiles from Corel 9 and Illustrator 88 do not operate properly if these operatorsare present.
Enables processing of DoPS directives in PDF files. DoPS has infact been deprecated for some time. Use of this option is notrecommended in security-conscious applications, as it increases thescope for malicious code. -dDOPS has no effect onprocessing of PostScript source files. Note: in releases 7.30 andearlier, processing of DoPS was always enabled.

Page parameters

Causes the media size to be fixed after initialization, forcing pagesof other sizes or orientations to be clipped. This may be useful whenprinting documents on a printer that can handle their requested paper sizebut whose default is some other size. Note that -gautomatically sets -dFIXEDMEDIA, but-sPAPERSIZE= does not.
Causes the media resolution to be fixed similarly. -rautomatically sets -dFIXEDRESOLUTION.
The page size from the PostScript file setpagedevice operator,or one of the older statusdict page size operators (such asletter or a4) will be rotated, scaled and centered on the"best fit" page size from those availiable in the InputAttributes list.The -dPSFitPage is most easily used to fit pages when used with the-dFIXEDMEDIA option.

This option is also set by the -dFitPage option.

Defines the meaning of the 0 and 1 orientation values for thesetpage[params] compatibility operators. The default value ofORIENT1 is true (set in, whichis the correct value for most files that use setpage[params] at all,namely, files produced by badly designed applications that "know" that theoutput will be printed on certain roll-media printers: these applicationsuse 0 to mean landscape and 1 to mean portrait.-dORIENT1=false declares that 0 means portrait and 1 meanslandscape, which is the convention used by a smaller number of filesproduced by properly written applications.
Sets the initial page width to w or initial page height toh respectively, specified in 1/72" units.
This value will be used to replace the device default papersize ONLYif the default papersize for the device is 'letter' or 'a4' servingto insulate users of A4 or 8.5x11 from particular device defaults(the collection of contributed drivers in Ghostscript vary as tothe default size).
This is a "convenience" operator that sets the various options to performpage fitting for specific file types.

This option sets the -dEPSFitPage, -dPDFFitPage, andthe -dFitPage options.

Font-related parameters

Causes individual character outlines to be loaded from the disk thefirst time they are encountered. (Normally Ghostscript loads all thecharacter outlines when it loads a font.) This may allow loading morefonts into memory at the expense of slower rendering.DISKFONTS is effective only if the diskfont feature wasbuilt into the executable; otherwise it is ignored.
Causes Type 1 fonts to be loaded into the current VM -- normally localVM -- instead of always being loaded into global VM. Useful only forcompatibility with Adobe printers for loading some obsolete fonts.
Suppresses the use of fonts precompiled into the Ghostscript executable.See "Precompiling fonts" in thedocumentation on fonts for details. This is probably useful only fordebugging.
Suppresses the normal loading of the Fontmap file. This may be usefulin environments without a file system.
Suppresses consultation of GS_FONTPATH. This may beuseful for debugging.
Disables the use of fonts supplied by the underlying platform (XWindows or Microsoft Windows). This may be needed if the platform fontslook undesirably different from the scalable fonts.
Disables the use of font map and corresponding fonts supplied by theunderlying platform. This may be needed to ensure consistent rendering onthe platforms with different fonts, for instance, during regression testing.
Specifies alternate name or names for the Fontmap file. Note that thenames are separated by ":" on Unix systems, by";" on MS Windows systems, and by"," on VMS systems, just as for search paths.
Specifies a list of directories that will be scanned when looking forfonts not found on the search path, overriding the environment variableGS_FONTPATH.
Causes the given font to be substituted for all unknown fonts, insteadof using the normal intelligent substitution algorithm. Also, in thiscase, the font returned by findfont is the actual fontnamed fontname, not a copy of the font with itsFontName changed to the requested one.THIS OPTION SHOULD NOT BE USED WITH HIGH LEVEL DEVICES, such aspdfwrite, because it prevents such devices fromproviding the original font names in the output document. Thefont specified (fontname) will be embedded instead,limiting all future users of the document to the same approximaterendering.
Reverts to using the old, sequential, PostScript CFF parser.New CFF parser is coded in C and uses direct access to the font data.This option and the old parser will be removed when the new parserproves its reliability.

Resource-related parameters

Specifies a path to resource files.The value is platform dependent. It must end with a directory separator.

A note for Windows users, Artifex recommends the use of theforward slash delimiter due to the special interpretation of \" bythe Microsoft C startup code. SeeParsing C Command-Line Argumentsfor more information.

Adobe specifies GenericResourceDir to be an absolute pathto a single resource directory. Ghostscript instead maintainsmultiple resource directories and uses an extended method for findingresources, which is explained in"Finding PostScript Level 2 resources".

Due to the extended search method, Ghostscript uses GenericResourceDironly as a default directory for resources being not installed.Therefore GenericResourceDir may be considered as a placewhere new resources to be installed. The default implementation of the functionResourceFileName uses GenericResourceDir when(1) it is an absolute path, or (2) the resource file is absent.The extended search method does not call ResourceFileName .

Default value is (./Resource/) for Unix, and an equivalent one on otherplatforms.

Specifies a path where font files are installed.It's meaning is similar to GenericResourceDir.

Default value is (./Font/) for Unix, and an equivalent one on otherplatforms.

Interaction-related parameters

Causes Ghostscript to exit after processing all files named on thecommand line, rather than going into an interactive loop reading PostScriptcommands. Equivalent to putting -c quit at the end of the command line.
Disables only the prompt, but not the pause, at the end of each page.This may be useful on PC displays that get confused if a program attemptsto write text to the console while the display is in a graphics mode.
Disables the prompt and pause at the end of each page. Normally oneshould use this (along with -dBATCH) when producing outputon a printer or to a file; it also may be desirable for applications whereanother program is "driving" Ghostscript.
Disables the prompt printed by Ghostscript when it expects interactiveinput, as well as the end-of-page prompt (-dNOPAGEPROMPT).This allows piping inputdirectly into Ghostscript, as long as the data doesn't refer tocurrentfile.
Suppresses routine information comments on standard output. This iscurrently necessary when redirecting device output to standard output.
Makes certain error and information messages more Adobe-compatible.
Redirect PostScript %stdout to a file orstderr, to avoid it being mixed with device stdout.To redirect stdout to stderr use -sstdout=%stderr.To cancel redirection of stdout use -sstdout=%stdoutor -sstdout=-.

Note that this redirects PostScript output to %stdout but does notchange the destination FILE of device output as with -sOutputFile=-or even -sOutputFile=%stdout since devices write directly usingthe stdout FILE * pointer with C function calls such as fwrite or fputs.

Causes Ghostscript to read a character from /dev/tty,rather than standard input, at the end of each page. This may be useful ifinput is coming from a pipe. Note that -dTTYPAUSEoverrides -dNOPAUSE.Also note that -dTTYPAUSE requires opening the terminaldevice directly, and may cause problems in combination with -dSAFER.Permission errors can be avoided by adding the device to the permittedreading list before invoking safer mode. For example:gs -dTTYPAUSE -dDELAYSAFER-c '<< /PermitFileReading [ (/dev/tty)] >>setuserparams .locksafe' -dSAFER

Device and output selection parameters

Initializes Ghostscript with a null device (a device that discards theoutput image) rather than the default device or the device selected with-sDEVICE=. This is usually useful only when runningPostScript code whose purpose is to compute something rather than toproduce an output image.
Selects an alternate initial outputdevice.
Selects an alternate output file (or pipe) for the initial outputdevice, as described above.
Some devices implement support for "printing" multiple copies of theinput document and some do not, usually based on whether it makes sensefor a particular output format. This switch instructs all devices toignore a request to print multiple copies, giving more consistentbehaviour.

Deferred Page Rendering

Raster printers and image formats that can use the "command list" (clist)to store a representation of the page prior to rendering can use the--saved-pages=string on the command line fordeferred rendering of pages.

Pages that are saved instead of printed are retained until thelist of saved pages is emptied by the flush command of thesaved-pages= command string.

Pages can be printed in reverse or normal order, or selected pages,including all even or all odd, and multiple collated copies can be produced.Since pages are saved until the flush command, pages can beprinted multiple times, in any order.

Refer to the SavedPages document fordetails.

EPS parameters

Crop an EPS file to the bounding box.This is useful when converting an EPS file to a bitmap.
Resize an EPS file to fit the page.This is useful for shrinking or enlarging an EPS file to fit the paper size when printing.

This option is also set by the -dFitPage option.

Prevent special processing of EPS files.This is useful when EPS files have incorrect DocumentStructuring Convention comments.

ICC color parameters

For details about the ICC controls see the documentGS9 Color Management.
Set the ICC profile that will be associated withundefined device gray color spaces. If this is not set,the profile file name "default_gray.icc" will be used asthe default.
Set the ICC profile that will be associated withundefined device RGB color spaces. If this is not set,the profile file name "default_rgb.icc" will be used asthe default.
Set the ICC profile that will be associated withundefined device CMYK color spaces. If this is not set,the profile file name "default_cmyk.icc" will be used asthe default.
Associate a DeviceN color space contained in a PS or PDFdocument with an ICC profile. Note that neither PS nor PDF providein-document ICC profile definitions for DeviceN color spaces.With this interface it is possible to provide this definition.The colorants tag order in the ICC profile defines the lay-downorder of the inks associated with the profile. A windows-basedtool for creating these source profiles is contained in./toolbin/color/icc_creator.
Set the ICC profile that will be associated withthe output device. Care should be taken to ensure that thenumber of colorants associated with the device is the sameas the profile. If this is not set, an appropriate profile(i.e. one with the proper number of colorants) will beselected from those in the directory specified by ICCProfilesDir (see below). Note that if the output device is CMYK + spot colorants, a CMYKprofile can be used to provide color management for the CMYK colorants only.In this case, spot colors will pass through unprocessed assuming thedevice supports those colorants. It is also possible for these devices tospecify NCLR ICC profiles for output.
-sICCOutputColors="Cyan, Magenta, Yellow, Black, Orange, Violet"
For the psdcmyk and tiffsep separation devices, the device ICC profile canbe an NCLR profile, which means something that includes non-traditional inkslike Orange, Violet, etc. In this case, the list of the colorant names in theorder that they exist in the profile must be provided with this command lineoption. Note that if a colorant name that is specified for the profile occurs also withinthe document (e.g. "Orange" above), then these colorants will be associated withthe same separation. It is possible through a compile time option LIMIT_TO_ICCdefined in gdevdevn.h to restrict the output colorants of the psdcmyk and tiffsepdevice to the colorants of the ICC profile or to allow additional spot colorantsin the document to be created as different separations. If restricted, the otherspot colorants will go through the alternate tint transform and then be mapped tothe color space defined by the NCLR profile. If an NCLR ICC profile is specifiedand ICCOutputColors is not used, then a set of default names will be used forthe extra colorants (non-CMYK) in the profile.
Enable the specificiation of a proofing profile that will make thecolor management system link multiple profiles together to emulate thedevice defined by the proofing profile. See the documentGS9 Color Management for details about this option.
Define a device link profile. This profile is used followingthe output device profile. Care should be taken to ensure that theoutput device process color model is the same as the output colorspace for the device link profile. In addition, the color space ofthe OutputICCProfile should match the input color space of the devicelink profile. For example, the following would be a valid specification-sDEVICE=tiff32nc -sOutputICCProfile=srgb.icc -sDeviceLinkProfile=linkRGBtoCMYK.icc.In this case, the output device's color model is CMYK (tiff32nc) and the colorsare mapped through sRGB and through a devicelink profile that maps sRGB toCMYK values. See the documentGS9 Color Management for details about this option.
Define a structure that is to be used by the color managementmodule (CMM) to provide color management of named colors. Whilethe ICC does define a named color format, this structure can inpractice be much more general. Many developers wish to usetheir own proprietary-based format for spot color management.This command option is for developer use when an implementationfor named color management is designed for the functiongsicc_transform_named_color located in gsicccache.c . An exampleimplementation is currently contained in the code for the handling of bothSeparation and DeviceN colors. For the general user this command optionshould really not be used.
Set the rendering intent that should be used with theprofile specified above by -sOutputICCProfile. Theoptions 0, 1, 2, and 3 correspond to the ICC intents of Perceptual, Colorimetric,Saturation, and Absolute Colorimetric.
Specify if black point compensation should be used with theprofile specified above by -sOutputICCProfile.
Specify if black preservation should be used when mappingfrom CMYK to CMYK. When using littleCMS as the CMM, the code 0corresponds to no preservation, 1 corresponds to the PRESERVE_K_ONLY approachdescribed in the littleCMS documentation and 2 corresponds to thePRESERVE_K_PLANE approach. This is only valid when using littleCMS forcolor management.
Set the ICC profile that will be associated withthe output device for vector-based graphics (e.g. Fill,Stroke operations).Care should be taken to ensure that thenumber of colorants associated with the device is the sameas the profile. This can be used to obtain more saturatedcolors for graphics.
Set the rendering intent that should be used with graphic objects. Theoptions are the same as specified for -dRenderIntent.
Specify if black point compensation should be used for graphic objects.
Specify if black preservation should be used when mappingfrom CMYK to CMYK for graphic objects. Theoptions are the same as specified for -dKPreserve.
Set the ICC profile that will be associated withthe output device for images.Care should be taken to ensure that thenumber of colorants associated with the device is the sameas the profile. This can be used to obtain perceptuallypleasing images.
Set the rendering intent that should be used for images.
Specify if black point compensation should be used with images.
Specify if black preservation should be used when mappingfrom CMYK to CMYK for image objects. Theoptions are the same as specified for -dKPreserve.
Set the ICC profile that will be associated withthe output device for text.Care should be taken to ensure that thenumber of colorants associated with the device is the sameas the profile. This can be used ensure K only text.
Set the rendering intent that should be used text objects. Theoptions are the same as specified for -dRenderIntent.
Specify if black point compensation should be used with text objects.
Specify if black preservation should be used when mappingfrom CMYK to CMYK for text objects. Theoptions are the same as specified for -dKPreserve.
Override any ICC profiles contained in the sourcedocument with the profiles specified bysDefaultGrayProfile, sDefaultRGBProfile, sDefaultCMYKProfile.Note that if no profiles are specified for the defaultDevice color spaces, thenthe system default profiles will be used. For detailed overridecontrol in the specification of source colors seeSourceObjectICC.
This option provides an extreme level of override control tospecify the source color spaces and rendering intents to usewith graphics, images and text for both RGB and CMYK sourceobjects. The specification is made through a file that containson a line a key name to specify the object type (e.g. Image_CMYK)followed by an ICC profile file name, a rendering intentnumber (0 for perceptual, 1 for colorimetric, 2 for saturation,3 for absolute colorimetric) and information for black point compensation,black preservation, and source ICC override. It is also possible to turnoff color management for certain object types, use device link profiles forobject types and do custom color replacements. An example file is given in./gs/toolbin/color/src_color/objsrc_profiles_example.txt.Profiles to demonstrate this method of specification are alsoincluded in this folder. Note that if objects are colorimetricallyspecified through this mechanism other operations like -dImageIntent,-dOverrideICC, have no affect. See further details in the documentGS9 Color Management.
By default, Ghostscript will map DeviceGray color spaces topure K when the output device is CMYK based. This may notalways be desired. In particular, it may be desired to mapfrom the gray ICC profile specified by -sDefaultGrayProfileto the output device profile. To achieve this, one shouldspecify -dDeviceGrayToK=false.
This is used to avoid the use of ICC profiles for source colors thatare defined by DeviceGray, DeviceRGB and DeviceCMYK definitions. WithUseFastColor set to true, the traditional Postscript 255 minus operationsare used to convert between RGB and CMYK with black generation and undercolorremoval mappings.
This option enables continous tone CMYK devices (e.g. tiff32nc) the capability toprovide a simulation of spot color overprinting. The default setting is true. Note that not all spot color overprint cases can be accurately simulated with a CMYK only device. For example, a case where you have a spot color overprinted with CMYKcolors will be indistiguishable from a case where you have spot color equivalent CMYK colorants overprinted with CMYK colors, even though they may need to show significantly different overprint simulations. To obtain a full overprint simulation,use the psdcmyk or tiffsep device, where the spot colors are kept in their own individual planes.
This option enables rendering with an output intent defined inthe PDF source file. If this option is included in the command line,source device color values (e.g DeviceCMYK, DeviceRGB, or DeviceGray)that match the color model of the output intent will be interpreted tobe in the output intent color space. In addition, if the output devicecolor model matches the output intent color model, then thedestination ICC profile will be the output intent ICC profile.If there is a mismatch between the device color model and theoutput intent, the output intent profile will be used as aproofing profile, since that is the intended rendering.Note that a PDF document can have multiplerendering intents per the PDF specification. As such, withthe option -dUsePDFX3Profile the first output intentencountered will be used. It is possible to specifya particular output intent where int is aninteger (a value of 0 is the same as not specifying a number).Probing of the output intents for a particular fileis possible using in ./gs/toolbin.Finally, note that the ICC profile member entry is an option inthe output intent dictionary. In these cases, the output intentspecifies a registry and a standard profile (e.g. Fogra39). Ghostscript willnot make use of these output intents. Instead, if desired, these standardprofiles should be used with the commands specified above (e.g. -sOutputICCProfile).
Set a directory in which to search for the above profiles.The directory path must end with a file system delimiter.

If the user doesn't use the -sICCProfilesDir= command line option,Ghostscript creates a default value for it by looking on thedirectory paths explained in HowGhostscript finds files. If the current directory is the firstpath a test is made for the iccprofiles directory. Next, the remainingpaths with the string Resource in it are tested. The prefix up tothe path separator character preceding the string Resource, concatenatedwith the string iccprofiles is used and if this exists, then thispath will be used for ICCProfilesDir.

Note that if the build is performed with COMPILE_INITS=1,then the profiles contained in gs/iccprofiles will be placed inthe ROM file system. If a directory is specified on the commandline using -sICCProfilesDir=, that directory is searched beforethe iccprofiles/ directory of the ROM file system is searched.

A note for Windows users, Artifex recommends the use of theforward slash delimiter due to the special interpretation of \" bythe Microsoft C startup code. SeeParsing C Command-Line Argumentsfor more information.

Other parameters

Causes bind to remember all its invocations, but notactually execute them until the .bindnow procedure iscalled. Useful only for certain specialized packages likepstotext that redefine operators. See the documentationfor .bindnow for more informationon using this feature.
Causes pdfmark to be called for bookmarks,annotations, links and cropbox when processing PDF files.Normally, pdfmark is only called for these typesfor PostScript files or when the output device requests it(e.g. pdfwrite device).
Define \004 (^D) to start a new encapsulated job used forcompatibility with Adobe PS Interpreters that ordinarily run under a jobserver. The -dNOOUTERSAVE switch is ignored if -dJOBSERVERis specified since job servers always execute the input PostScriptunder a save level, although the exitserver operator canbe used to escape from the encapsulated job and execute as if the-dNOOUTERSAVE was specified.

This also requires that the input be from stdin, otherwise an error willresult (Error: /invalidrestore in --restore--).

Example usage is:

    gs ... -dJOBSERVER - <
    cat | gs ... -dJOBSERVER -
Note: The ^D does not result in an end-of-file actionon stdin as it may on some PostScript printers that rely on TBCP (TaggedBinary Communication Protocol) to cause an out-of-band ^D tosignal EOF in a stream input data. This means that direct file actionson stdin such as flushfile and closefilewill affect processing of data beyond the ^D in the stream.
Disables the bind operator. Useful only for debugging.
Disables character caching. Useful only for debugging.
Suppresses the initial automatic enabling of the garbage collector inLevel 2 systems. (The vmreclaim operator is not disabled.)Useful only for debugging.
Suppresses the initial save that is used for compatibility with AdobePS Interpreters that ordinarily run under a job server. If a job server isgoing to be used to set up the outermost save level, then -dNOOUTERSAVEshould be used so that the restore between jobs will restore global VM asexpected.
-dNOSAFER (equivalent to -dDELAYSAFER).
This flag disables SAFER mode until the .setsafeprocedure is run. This is intended for clients or scripts that cannotoperate in SAFER mode. If Ghostscript is started with -dNOSAFERor -dDELAYSAFER, PostScript programs are allowed to read, write,rename or delete any files in the system that are not protected by operatingsystem permissions.

This mode should be used with caution, and .setsafe should berun prior to running any PostScript file with unknown contents.

Disables the deletefile and renamefileoperators, and the ability to open piped commands (%pipe%cmd)at all. Only %stdout and %stderr can be openedfor writing. Disables reading of files other than %stdin,those given as a command line argument, or those contained on one of the pathsgiven by LIBPATH and FONTPATH and specified by the system params /FontResourceDirand /GenericResourceDir.

This mode also sets the .LockSafetyParamsparameter of the default device, or the device specified with the -sDEVICE= switch to protect against programs that attempt to write to files using theOutputFile device parameter. Note that since the device parameters specifiedon the command line (including OutputFile) are set prior to SAFER mode,the -sOutputFile=... on the command line is unrestricted.

SAFER mode also prevents changing the /GenericResourceDir, /FontResourceDirand either the /SystemParamsPassword or the /StartJobPassword.

Note: While SAFER mode is not the default, in a subsequent release ofGhostscript, SAFER mode will be the default thus scripts or programs that needto open files or set restricted parameters will require the -dNOSAFERcommand line option.

When running -dNOSAFER it is possible to perform a save,followed by .setsafe, execute a file or procedure in SAFER mode,then use restore to return to NOSAFER mode. In order to preventthe save object from being restored by the foreign file or procedure, the.runandhide operator shouldbe used to hide the save object from the restricted procedure.

If the target device is a halftone device, then images that are normally stored in the command list during banded output will be halftoned duringthe command list writing phase, if the resulting image will result in a smaller command list. The decision to halftone depends upon the output and source resolution as well as the output and source color space.
Disables as many Ghostscript extensions as feasible, to be more helpfulin debugging applications that produce output for Adobe and other RIPs.
Leaves systemdict writable. This is necessary whenrunning special utility programs such as font2c andpcharstr, which must bypass normal PostScript accessprotection.

Improving performance

Ghostscript attempts to find an optimum balance between speed and memoryconsumption, but there are some cases in which you may get a very largespeedup by telling Ghostscript to use more memory.

  • For raster printers and image format (jpeg*, tiff*, png* ...) devices,performance can be 'tuned' by adjusting some of the parameters relatedto banding (clist) options (refer to: Banding Parameters).

    All devices may use a display list ("clist") and use banding when processingPDF 1.4 transparency. This prevents allocation of excessively large amounts ofmemory for the transparency buffer stack. The -dMaxBitmap= optionis used to control when to use the display list, and the other banding parametersmentioned above control the band size.

    In general, page buffer mode is faster than banded/clist mode (a full pagebuffer is used when -dMaxBitmap=# is large enough for the entireraster image) since there is no need to write, then interpret the clist data.

    On a multi-core system where multiple threads can be dispatched toindividual processors/cores, banding mode may provide higher performancesince -dNumRenderingThreads=# can be used to take advantage ofmore than one CPU core when rendering the clist. The number of threads shouldgenerally be set to the number of available processor cores for best throughput.

    In general, larger -dBufferSpace=# values provideslightly higher performance since the per-band overhead is reduced.

  • If you are using X Windows, setting the -dMaxBitmap=parameter described above maydramatically improve performance on files that have a lot of bitmap images.
  • With some PDF files, or if you are using Chinese, Japanese, or other fonts withvery large character sets, adding the following sequence of switches before thefirst file name may dramatically improve performance at the cost of an additionalmemory. For example, to allow use of 30Mb of extra RAM use:

    -c 30000000 setvmthreshold -f.

    This can also be useful in processing large documents when using ahigh-level output device (like pdfwrite) that maintains significant internalstate. In fact, the .setpdfwriteoperator used by the ps2pdf script and others sets a vmthreshold value of3 MB to account for this.

  • For pattern tiles that are very large, Ghostscript uses an internal displaylist (memory based clist), but this can slow things down. The current defaultthreshold is 8Mb -- pattern tiles larger than this will be cached as clistrather than bitmap tiles. The parameter -dMaxPatternBitmap=# canbe used to adjust this threshold, smaller to reduce memory requirements andlarger to avoid performance impacts due to clist based pattern handling.

    For example, -dMaxPatternBitmap=200000 will use clist basedpatterns for pattern tiles larger than 200,000 bytes.

Summary of environment variables

GS, GSC (MS Windows only)
Specify the names of the Ghostscript executables. GSbrings up a new typein window and possibly a graphics window;GSC uses the DOS console. If these are not set,GS defaults to gswin32, andGSC defaults to gswin32c.
Defines the default output device. This overrides the compiled-in default, but is overridden by any commandline setting.
Specifies a list of directories to scan for fonts if a font requestedcan't be found anywhere on the search path.
Provides a search path for initialization files and fonts.
Defines a list of command-line arguments to be processed before theones actually specified on the command line. For example, settingGS_DEVICE to XYZ is equivalent to settingGS_OPTIONS to -sDEVICE=XYZ. The contentsof GS_OPTIONS are not limited to switches; they may includeactual file names or even "@file" arguments.
Defines a directory name for temporary files. If bothTEMP and TMPDIR are defined,TMPDIR takes precedence.


The information here describing is probably interesting only to developers.

Debug switches

There are several debugging switches that are detected by the interpreter.These switches are available whether or not Ghostscript was built with theDEBUG macro defined to the compiler (refer to building a debugging configuration).

Previous to 8.10, there was a single DEBUG flag, enabled with -dDEBUG on the command line. Now there are several debugging flags to allowmore selective debugging information to be printed containing only what isneeded to investigate particular areas. For backward compatibilty, the-dDEBUG option will set all of the subset switches.

-dCCFONTDEBUG   Compiled Fonts
-dEPSDEBUG   EPS handling
-dINITDEBUG   Initialization
-dPDFDEBUG   PDF Interpreter
-dSETPDDEBUG   setpagedevice
-dSTRESDEBUG   Static Resources

Normally, PDF interpreter tries to repair all problems in PDF files.-dPDFSTOPONERROR skips some of the stopped contexts. On error,instead of printing a warning and continue, PDF interpreter drops intoa PostScript error handler that prints detailed information about the problem andkills the job.

With switching to freetype 2 as the default font renderer in April 2010, weadded a new switch:-dDisableFAPI=true to revert to the olderbehavior, just in case serious regression happens that cannot be resolved in a timely manner.

The -Z and -T switches apply onlyif the interpreter was built for a debuggingconfiguration. In the table below, the first column is a debuggingswitch, the second is an equivalent switch (if any) and the third is itsusage.

Switches used in debugging
Switch   Equivalent    

-A   -Z@   Fill empty storage with a distinctive bit pattern for debugging
-A-   -Z-@   Turn off -A
-Bsize       Run all subsequent files named on the command line (except for -F) through the run_string interface, using a buffer of size bytes
-B-       Turn off -B: run subsequent files (except for -F) directly in the normal way
-E   -Z#   Turn on tracing of error returns from operators
-E-   -Z-#   Turn off -E
-Ffile       Execute the file with -B1 temporarily in effect
-Kn       Limit the total amount of memory that the interpreter can have allocated at any one time to nK bytes. n is a positive decimal integer.
-Mn       Force the interpreter's allocator to acquire additional memory in units of nK bytes, rather than the default 20K. n is a positive decimal integer, on 16-bit systems no greater than 63.
-Nn       Allocate space for nK names, rather than the default (normally 64K). n may be greater than 64 only if EXTEND_NAMES was defined (in inameidx.h) when the interpreter was compiled .
      Turn debugging printout on (off). Each of the xxx characters selects an option. Case is significant: "a" and "A" have different meanings.
garbage collector, minimal detail
type 1 and type 42 font interpreter
curve subdivider/rasterizer
curve subdivider/rasterizer, detail
garbage collector (strings)
garbage collector (strings, detail)
garbage collector (chunks, roots)
garbage collector (objects)
garbage collector (refs)
garbage collector (pointers)
allocator (large blocks only)
allocator (all calls)
bitmap image processor
bitmap images, detail
color/halftone mapper
dictionary put/undef
dictionary lookups
external (OS-related) calls
fill algorithm (summary)
fill algorithm (detail)
halftone renderer
halftones, every pixel
interpreter, just names
interpreter, everything
(Japanese) composite fonts
character cache and xfonts
character cache, every access
command lists, bands
command lists, everything
makefont and font cache
name lookup (new names only)
outliner (stroke)
stroke detail
band list paths
all paths
arc renderer
tiling algorithm
undo saver (for save/restore), finalization
undo saver, more detail
compositors: alpha/transparency/overprint/rop
compositors: alpha/transparency/overprint/rop, more detail
compression encoder/decoder
Type 1 hints
Type 1 hints, every access
trapezoid fill
operator error returns
externally processed comments
image and RasterOp parameters
command list and allocator/time summary
math functions and Functions
contexts, create/destroy
contexts, every operation
reference counting
high-level output
Postscript operator names (this option is available onlywhen Ghostscript is compiled with a predefined macro DEBUG_TRACE_PS_OPERATORS)
(reserved for experimental code)

The following switch affects what is printed, but does not select specificitems for printing:

include file name and line number on all trace output

These switches select debugging options other than what should be printed:

set unused parts of object references toidentifiable garbage values
use minimum-size stack blocks
don't use path-based banding
don't use high-level banded images
validate pointers before, during and after garbagecollection, also before and after save and restore; also make otherallocator validity checks
fill newly allocated, garbage-collected, and freedstorage with a marker (a1, c1, and f1 respectively)

      Turn Visual Trace on (off). Each of the xxx characters selects an option. Case is significant: "f" and "F" have different meanings.
the filling algorithm with characters
the filling algorithm with non-character paths
the Type 1 hinter
the shading algorithm
the stroking algorithm

In addition, calling ghostscript with --debug will list all the currentlydefined (non visual trace) debugging flags, both in their short form (as listedabove for use with -Z) and in a long form, which can be used as in:--debug=tiling,alloc. All the short form flags for -Zhave an equivalent long form. Future flags may be added with a long form only(due to all the short form flags being used already).

Visual Trace

Visual Trace allows to view internal Ghostscript data in a graphical formwhile execution of C code. Specialinstructions to be inserted intoC code for generating the output. Client applicationrasterizes it into a window.

Currently the rasterization is implemented for Windows only, in clientsgswin32.exe and gswin32c.exe. They open Visual Trace window when graphicaldebug output appears, -T switch is set,and Ghostscript was built with DEBUG option.There are two important incompletenesses of the implementation :

1. The graphical output uses a hardcoded scale. An advanced clientwould provide a scale option via user interface.

2. Breaks are not implemented in the client. If you need a step-by-stepview, you should use an interactive C debugger to delay execution at breakpoints.

Appendix: Paper sizes known to Ghostscript

The paper sizes known to Ghostscript are defined at the beginning of theinitialization file; see the comments there formore details about the definitions. The table here lists them by name andsize. defines their sizes exactly in points,and the dimensions in inches (at 72 points per inch) and centimeters shownin the table are derived from those, rounded to the nearest 0.1 unit. Aguide to international paper sizes can be found at

Paper sizes known to Ghostscript
U.S. standard
    Inches   mm   Points    
Name    W  ×  H     W  ×  H     W  ×  H     

11x17   11.0   17.0   279   432   792   1224   11×17in portrait
ledger   17.0   11.0   432   279   1224   792   11×17in landscape
legal   8.5   14.0   216   356   612   1008    
letter   8.5   11.0   216   279   612   792    
lettersmall   8.5   11.0   216   279   612   792    
archE   36.0   48.0   914   1219   2592   3456    
archD   24.0   36.0   610   914   1728   2592    
archC   18.0   24.0   457   610   1296   1728    
archB   12.0   18.0   305   457   864   1296    
archA   9.0   12.0   229   305   648   864    

ISO standard

a0   33.1   46.8   841   1189   2384   3370    
a1   23.4   33.1   594   841   1684   2384    
a2   16.5   23.4   420   594   1191   1684    
a3   11.7   16.5   297   420   842   1191    
a4   8.3   11.7   210   297   595   842    
a4small   8.3   11.7   210   297   595   842    
a5   5.8   8.3   148   210   420   595    
a6   4.1   5.8   105   148   297   420    
a7   2.9   4.1   74   105   210   297    
a8   2.1   2.9   52   74   148   210    
a9   1.5   2.1   37   52   105   148    
a10   1.0   1.5   26   37   73   105    
isob0   39.4   55.7   1000   1414   2835   4008    
isob1   27.8   39.4   707   1000   2004   2835    
isob2   19.7   27.8   500   707   1417   2004    
isob3   13.9   19.7   353   500   1001   1417    
isob4   9.8   13.9   250   353   709   1001    
isob5   6.9   9.8   176   250   499   709    
isob6   4.9   6.9   125   176   354   499    
c0   36.1   51.1   917   1297   2599   3677    
c1   25.5   36.1   648   917   1837   2599    
c2   18.0   25.5   458   648   1298   1837    
c3   12.8   18.0   324   458   918   1298    
c4   9.0   12.8   229   324   649   918    
c5   6.4   9.0   162   229   459   649    
c6   4.5   6.4   114   162   323   459    

JIS standard

jisb0           1030   1456            
jisb1           728   1030            
jisb2           515   728            
jisb3           364   515            
jisb4           257   364            
jisb5           182   257            
jisb6           128   182            

ISO/JIS switchable

b0 (see * below)
b1 (see * below)
b2 (see * below)
b3 (see * below)
b4 (see * below)
b5 (see * below)


flsa   8.5   13.0   216   330   612   936   U.S. foolscap
flse   8.5   13.0   216   330   612   936   European foolscap
halfletter   5.5   8.5   140   216   396   612    
hagaki   3.9   5.8   100   148   283   420   Japanese postcard

*Note: Initially the B paper sizes are the ISO sizes, e.g.,b0 is the same as isob0. Running the filelib/ makes the B paper sizes be the JIS sizes,e.g., b0 becomes the same as jisb0.

Appendix: X default font mappings

Standard X servers

Regular fonts

    AvantGarde-Book:              -Adobe-ITC Avant Garde Gothic-Book-R-Normal--\n\
    AvantGarde-BookOblique:       -Adobe-ITC Avant Garde Gothic-Book-O-Normal--\n\
    AvantGarde-Demi:              -Adobe-ITC Avant Garde Gothic-Demi-R-Normal--\n\
    AvantGarde-DemiOblique:       -Adobe-ITC Avant Garde Gothic-Demi-O-Normal--\n\
    Bookman-Demi:                 -Adobe-ITC Bookman-Demi-R-Normal--\n\
    Bookman-DemiItalic:           -Adobe-ITC Bookman-Demi-I-Normal--\n\
    Bookman-Light:                -Adobe-ITC Bookman-Light-R-Normal--\n\
    Bookman-LightItalic:          -Adobe-ITC Bookman-Light-I-Normal--\n\
    Courier:                      -Adobe-Courier-Medium-R-Normal--\n\
    Courier-Bold:                 -Adobe-Courier-Bold-R-Normal--\n\
    Courier-BoldOblique:          -Adobe-Courier-Bold-O-Normal--\n\
    Courier-Oblique:              -Adobe-Courier-Medium-O-Normal--\n\
    Helvetica:                    -Adobe-Helvetica-Medium-R-Normal--\n\
    Helvetica-Bold:               -Adobe-Helvetica-Bold-R-Normal--\n\
    Helvetica-BoldOblique:        -Adobe-Helvetica-Bold-O-Normal--\n\
    Helvetica-Narrow:             -Adobe-Helvetica-Medium-R-Narrow--\n\
    Helvetica-Narrow-Bold:        -Adobe-Helvetica-Bold-R-Narrow--\n\
    Helvetica-Narrow-BoldOblique: -Adobe-Helvetica-Bold-O-Narrow--\n\
    Helvetica-Narrow-Oblique:     -Adobe-Helvetica-Medium-O-Narrow--\n\
    Helvetica-Oblique:            -Adobe-Helvetica-Medium-O-Normal--\n\
    NewCenturySchlbk-Bold:        -Adobe-New Century Schoolbook-Bold-R-Normal--\n\
    NewCenturySchlbk-BoldItalic:  -Adobe-New Century Schoolbook-Bold-I-Normal--\n\
    NewCenturySchlbk-Italic:      -Adobe-New Century Schoolbook-Medium-I-Normal--\n\
    NewCenturySchlbk-Roman:       -Adobe-New Century Schoolbook-Medium-R-Normal--\n\
    Palatino-Bold:                -Adobe-Palatino-Bold-R-Normal--\n\
    Palatino-BoldItalic:          -Adobe-Palatino-Bold-I-Normal--\n\
    Palatino-Italic:              -Adobe-Palatino-Medium-I-Normal--\n\
    Palatino-Roman:               -Adobe-Palatino-Medium-R-Normal--\n\
    Times-Bold:                   -Adobe-Times-Bold-R-Normal--\n\
    Times-BoldItalic:             -Adobe-Times-Bold-I-Normal--\n\
    Times-Italic:                 -Adobe-Times-Medium-I-Normal--\n\
    Times-Roman:                  -Adobe-Times-Medium-R-Normal--\n\
    ZapfChancery-MediumItalic:    -Adobe-ITC Zapf Chancery-Medium-I-Normal--

Symbol fonts

    Symbol:                       -Adobe-Symbol-Medium-R-Normal--

Dingbat fonts

    ZapfDingbats:                 -Adobe-ITC Zapf Dingbats-Medium-R-Normal--

Sun OpenWindows

For Sun's X11/NeWS one can use the OpenWindows scalable fonts instead,which gives good output for any point size. In this environment, therelevant section of the resource file should look like this:

Ghostscript.regularFonts: \
    AvantGarde-Book:              -itc-avantgarde-book-r-normal-- \n\
    AvantGarde-BookOblique:       -itc-avantgarde-book-o-normal-- \n\
    AvantGarde-Demi:              -itc-avantgarde-demi-r-normal-- \n\
    AvantGarde-DemiOblique:       -itc-avantgarde-demi-o-normal-- \n\
    Bembo:                        -monotype-bembo-medium-r-normal-- \n\
    Bembo-Bold:                   -monotype-bembo-bold-r-normal-- \n\
    Bembo-BoldItalic:             -monotype-bembo-bold-i-normal-- \n\
    Bembo-Italic:                 -monotype-bembo-medium-i-normal-- \n\
    Bookman-Demi:                 -itc-bookman-demi-r-normal-- \n\
    Bookman-DemiItalic:           -itc-bookman-demi-i-normal-- \n\
    Bookman-Light:                -itc-bookman-light-r-normal-- \n\
    Bookman-LightItalic:          -itc-bookman-light-i-normal-- \n\
    Courier:                      -itc-courier-medium-r-normal-- \n\
    Courier-Bold:                 -itc-courier-bold-r-normal-- \n\
    Courier-BoldOblique:          -itc-courier-bold-o-normal-- \n\
    Courier-Oblique:              -itc-courier-medium-o-normal-- \n\
    GillSans:                     -monotype-gill-medium-r-normal-sans- \n\
    GillSans-Bold:                -monotype-gill-bold-r-normal-sans- \n\
    GillSans-BoldItalic:          -monotype-gill-bold-i-normal-sans- \n\
    GillSans-Italic:              -monotype-gill-normal-i-normal-sans- \n\
    Helvetica:                    -linotype-helvetica-medium-r-normal-- \n\
    Helvetica-Bold:               -linotype-helvetica-bold-r-normal-- \n\
    Helvetica-BoldOblique:        -linotype-helvetica-bold-o-normal-- \n\
    Helvetica-Narrow:             -linotype-helvetica-medium-r-narrow-- \n\
    Helvetica-Narrow-Bold:        -linotype-helvetica-bold-r-narrow-- \n\
    Helvetica-Narrow-BoldOblique: -linotype-helvetica-bold-o-narrow-- \n\
    Helvetica-Narrow-Oblique:     -linotype-helvetica-medium-o-narrow-- \n\
    Helvetica-Oblique:            -linotype-helvetica-medium-o-normal-- \n\
    LucidaBright:                 -b&h-lucidabright-medium-r-normal-- \n\
    LucidaBright-Demi:            -b&h-lucidabright-demibold-r-normal-- \n\
    LucidaBright-DemiItalic:      -b&h-lucidabright-demibold-i-normal-- \n\
    LucidaBright-Italic:          -b&h-lucidabright-medium-i-normal-- \n\
    LucidaSans:                   -b&h-lucida-medium-r-normal-sans- \n\
    LucidaSans-Bold:              -b&h-lucida-bold-r-normal-sans- \n\
    LucidaSans-BoldItalic:        -b&h-lucida-bold-i-normal-sans- \n\
    LucidaSans-Italic:            -b&h-lucida-medium-i-normal-sans- \n\
    LucidaSans-Typewriter:        -b&h-lucidatypewriter-medium-r-normal-sans- \n\
    LucidaSans-TypewriterBold:    -b&h-lucidatypewriter-bold-r-normal-sans- \n\
    NewCenturySchlbk-BoldItalic:  -linotype-new century schoolbook-bold-i-normal-- \n\
    NewCenturySchlbk-Bold:        -linotype-new century schoolbook-bold-r-normal-- \n\
    NewCenturySchlbk-Italic:      -linotype-new century schoolbook-medium-i-normal-- \n\
    NewCenturySchlbk-Roman:       -linotype-new century schoolbook-medium-r-normal-- \n\
    Palatino-Bold:                -linotype-palatino-bold-r-normal-- \n\
    Palatino-BoldItalic:          -linotype-palatino-bold-i-normal-- \n\
    Palatino-Italic:              -linotype-palatino-medium-i-normal-- \n\
    Palatino-Roman:               -linotype-palatino-medium-r-normal-- \n\
    Rockwell:                     -monotype-rockwell-medium-r-normal-- \n\
    Rockwell-Bold:                -monotype-rockwell-bold-r-normal-- \n\
    Rockwell-BoldItalic:          -monotype-rockwell-bold-i-normal-- \n\
    Rockwell-Italic:              -monotype-rockwell-medium-i-normal-- \n\
    Times-Bold:                   -linotype-times-bold-r-normal-- \n\
    Times-BoldItalic:             -linotype-times-bold-i-normal-- \n\
    Times-Italic:                 -linotype-times-medium-i-normal-- \n\
    Times-Roman:                  -linotype-times-medium-r-normal-- \n\
    Utopia-Bold:                  -adobe-utopia-bold-r-normal-- \n\
    Utopia-BoldItalic:            -adobe-utopia-bold-i-normal-- \n\
    Utopia-Italic:                -adobe-utopia-regular-i-normal-- \n\
    Utopia-Regular:               -adobe-utopia-regular-r-normal-- \n\
    ZapfChancery-MediumItalic:    -itc-zapfchancery-medium-i-normal-- \n
Ghostscript.dingbatFonts: \
    ZapfDingbats:                 -itc-zapfdingbats-medium-r-normal--
Ghostscript.symbolFonts: \
    Symbol:                       --symbol-medium-r-normal--

Running Ghostscript with third-party font renderers

Font API (FAPI) is a feature which allows to attach third-party fontrenderers to Ghostscript.This section explains how to run Ghostscript with third-party fontrenderers, such as UFST. NOTE: FreeType is now the default font rendererfor Ghostscript.

Note: To run Ghostscript with UFST you need a license from Monotype Imaging.Please ignore issues about UFST if you haven't got it.

Important note: Third-party font renderers may be incompatiblewith devices that can embed fonts in their output (such as pdfwrite),because such renderers may store fonts in a form from which Ghostscript cannotget the necessary information for embedding, for example, the Microtype fonts suppliedwith the UFST. Ghostscript can be configured to disable such renderers when such adevice is being used.

As of Ghostscript version 9.0, Ghostscript uses Freetype 2.4.x as the default fontscaler/renderer.With this change, we added a new switch:-dDisableFAPI=true to revert to the olderbehavior, just in case serious regression happens that cannot be resolved in a timely manner.It is intended that this switch will be removed once the FAPI/Freetype implementation hasproven itself robust and reliable in the "real world".

To run Ghostscript with UFST, you first need to build Ghostscriptwith the UFST bridge. Refer How to build Ghostscript with UFST.Both bridges may run together.

There are 2 ways to handle fonts with a third-party font renderer (FAPI).First, you can substituteany FAPI-handled font to a resident PostScript font, using special map filesFAPIfontmap and FAPIcidfmap.Second, you can redirect PostScript fonts to FAPI, settingentries in FAPIconfig file.

Names FAPIfontmap, FAPIcidfmap, FAPIconfigin this text actually are placeholders, which may be substituted with command line arguments :-sFAPIfontmap=name1 -sFAPIcidfmap=name2-sFAPIconfig=name3.Ghostscript searches the specified file names as explained inHow Ghostscript finds files.Default values for these arguments are equal to argument names.When building Ghostscript with COMPILE_INITS=1, only default values are used.

Font files, which are being handled with FAPI, may reside in any directory in your hard disk.Paths to them to be specified in FAPIfontmap andwith special command line arguments, explained below.The path may be either absolute or relative. Relative ones are being resolved from the path,which is specified in FAPIconfig file.

The file FAPIfontmap is actually special PostScript code.It may include records of 2 types : general recordsand FCO records (see below).

A general record describes a font, which is being rendered with FAPI.They must end with semicolon. Each general record is a pair.The first element of the pair is the font name (the name that PostScriptdocuments use to access the font, which may differfrom real name of the font which the font file defines).The second element is a dictionary with entries :

Key Type Description
Path string Absolute path to font file, or relative path to font file from the FontPath value, being specified in FAPIconfig.
FontType interger PostScript type for this font. Only 1 and 42 are currently allowed. Note that this is unrelated to the real type of the font file - the bridge will perform a format conversion.
FAPI name Name of the renderer to be used with the font. Only /UFST and /FreeType are now allowed.
SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC. It is being ignored if Path doesn't specify a collection. Note that Free Type can't handle FCO. Default value is 0.
Decoding name (optional) The name of a Decoding resource to be used with the font. If specified, lib/xlatmap (see below) doesn't work for this font.

Example of a general FAPI font map record :

/FCO1 << /Path (/AFPL/UFST/fontdata/MTFONTS/PCLPS3/MT1/PCLP3__F.fco) /FontType 1 /FAPI /UFST >> ;

FCO records work for UFST only.A group of FCO records start with a line name ReadFCOfontmap:,where name is a name of a command line argument,which specify a path to an FCO file. The group of FCO recordsmust end with the line EndFCOfontmap.Each record of a group occupy a single line,and contains a number and 1, 2 or 3 names.The number is the font index in the FCO file, the first nameis the Postscript font name, the secong is an Encoding resource name,and the third is a decoding resource name.

Note that FAPIfontmap specifies only instances ofFont category. CID fonts to be listed in another map file.

Ghostscript distribution includes sample map filesgs/lib/FAPIfontmap,gs/lib/FCOfontmap-PCLPS2,gs/lib/FCOfontmap-PCLPS3,gs/lib/FCOfontmap-PS3,which may be customized by the user.The last 3 ones include an information about UFST FCO files.

The file FAPIcidfmap defines a mapping table forCIDFont resources. It contains records for each CID font being rendered with FAPI.The format is similar to FAPIfontmap,but dictionaries must contain few different entries :

Key Type Description
Path string Absolute path to font file, or relative path to font file from the CIDFontPath value, being specified in FAPIconfig.
CIDFontType interger PostScript type for this CID font. Only 0, 1 and 2 are currently allowed. Note that this is unrelated to the real type of the font file - the bridge will perform format conversion.
FAPI name Name of the renderer to be used with the font. Only /UFST and /FreeType are now allowed.
SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC. It is being ignored if Path doesn't specify a collection. Default value is 0.
CSI array of 2 elements (required) Information for building CIDSystemInfo. The first element is a string, which specifies Ordering. The second element is a number, which specifies Supplement.

Example of FAPI CID font map record :

/HeiseiKakuGo-W5 << /Path (/WIN2000/Fonts/PMINGLIU.TTF) /CIDFontType 0 /FAPI /UFST /CSI [(Japan1) 2] >> ;

The control file FAPIconfig defines 4 entries :

Key Type Description
FontPath string Absolute path to a directory, which contains fonts. Used to resolve relative paths in FAPIfontmap.
CIDFontPath string Absolute path to a directory, which contains fonts to substitute to CID fonts. Used to resolve relative paths in FAPIcidfmap. It may be same or different than FontPath.
HookDiskFonts array of integers. List of PS font types to be handled with FAPI. This controls other fonts that ones listed in FAPIfontmap and FAPIcidfmap - such ones are PS fonts installed to Ghostscript with lib/fontmap or with GS_FONTPATH, or regular CID font resources. Unlisted font types will be rendered with the native Ghostscript font renderer. Only allowed values now are 1,9,11,42. Note that 9 and 11 correspond to CIDFontType 0 and 2.
HookEmbeddedFonts array of integers. List of PS font types to be handled with FAPI. This controls fonts being embedded into a document - either fonts or CID font resources. Unlisted font types will be rendered with the native Ghostscript font renderer. Only allowed values now are 1,9,11,42. Note that 9 and 11 correspond to CIDFontType 0 and 2.

Ghostscript distribution includes sample config filesgs/lib/FAPIconfig,gs/lib/FAPIconfig-FCO.which may be customized by the user.The last ones defines the configurationfor handling resident UFST fonts only.

In special cases you may need to customize the file lib/xlatmap. Follow instructions in it.

Some UFST font collections need a path for finding an UFST plugin.If you run UFST with such font collection,you should run Ghostscript with a special command line argument-sUFST_PlugIn=path, where path specifiesa disk path to the UFST plugin file, which Monotype Imaging distributesin ufst/fontdata/MTFONTS/PCL45/MT3/plug__xi.fco.If UFST needs it and thecommand line argument is not specified, Ghostscript prints a warning and searchesplugin file in the current directory.

If you want to run UFST with resident UFST fonts only(and allow Ghostscript font renderer to handle fons, which may be downloaded or embedded into documents),you should run Ghostscript with these command line arguments :-sFCOfontfile=path1 -sFCOfontfile2=path2-sUFST_PlugIn=path3-sFAPIfontmap=map-name -sFAPIconfig=FAPIconfig-FCOwhere path1 specifiesa disk path to the main FCO file, path2 specifiesa disk path to the Wingdings FCO file, path3a disk path the FCO plugin file, path1 is eithergs/lib/FCOfontmap-PCLPS2,gs/lib/FCOfontmap-PCLPS3, orgs/lib/FCOfontmap-PS3.FAPIcidfmap works as usual, but probably you want to leave it emptybecause FCO doesn't emulate CID fonts.

Some configurations of UFST need a path for finding symbol set files.If you compiled UFST with such configuration,you should run Ghostscript with a special command line argument-sUFST_SSdir=path, where path specifiesa disk path to the UFST support directory, which Monotype Imagong distributesin ufst/fontdata/SUPPORT. If UFST needs it and thecommand line argument is not specified, Ghostscript prints a warning and searchessymbol set files in the current directory.

Note that UFST and Free Type cannot handle some Ghostscript fonts becausethey do not include a PostScript interpreter and therefore have stronger restrictions onfont formats than Ghostscript itself does - in particular, Type 3 fonts.If their font types are listed in HookDiskFonts or inHookEmbeddedFonts, Ghostscript interprets them as PS files,then serializes font data into a RAM buffer and passes it to FAPI asPCLEOs. (see the FAPI-related source code for details).

Copyright © 2000-2010 Artifex Software, Inc. All rights reserved.

This software is provided AS-IS with no warranty, either express orimplied.This software is distributed under license and may not be copied, modifiedor distributed except as expressly authorized under the terms of thatlicense. Refer to licensing information at contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.

Ghostscript version 9.15, 22 September 2014

安全 Shell 测试技术
Metasploit -- 目录详解及常用命令
Metasploit -- 目录详解及常用命令
78 0
Metasploit -- 目录详解及常用命令
Cypress系列(96)- exec() 命令详解
Cypress系列(96)- exec() 命令详解
132 0
Cypress系列(96)- exec() 命令详解
NoSQL Linux 编译器
NoSQL Linux 开发工具
拷贝文件防止覆盖使用 “cp –i” 操作 拷贝文件夹使用 “cp –r” 操作,拷贝文件夹并且文件权限不丢失使用 “cp –a” 操作。 移动文件防止覆盖使用 “mv –i” 操作 移动文件夹直接使用 “mv” 即可,“mv” 还可以给文件和文件夹重命名。
475 0
984 0