GhostScript命令参数详解

本文列出几个常用参数,然后下面附上官方的参数详解:

一、常用参数解释

这是一个测试的命令: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(根据自己安装的版本)。

这里注意一下的是:

1、安装目录下有带“c”的和不带c的,我们使用带c的,不会弹出界面。

2、如果我们使用java代码调用,建议不添加“-dQUIET”,因为不添加该参数,会输出日志,这样便于我们判断捕获解析的日志,以及分析页数。


相关参数如下说明:

    "-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

  • Invoking Ghostscript
    • Help at the command line: gs -h
  • Selecting an output device
    • Output resolution
    • Output to files
      • One page per file
    • Choosing paper size
    • Changing the installed default paper size
  • Interacting with pipes
  • Using Ghostscript with PDF files
    • Switches for PDF files
    • Problems interpreting a PDF file
    • PDF files from standard input
  • Using Ghostscript with EPS files
  • Using Ghostscript with overprinting and spot colors
  • How Ghostscript finds files
    • Finding PostScript Level 2 resources
    • Font lookup
    • CID fonts
    • CID font substitution
    • Using Unicode True Type fonts
    • Temporary files
  • Notes on specific platforms
    • Unix
    • VMS
      • Using X Windows on VMS
    • MS Windows
    • X Windows
      • X resources
      • Working around bugs in X servers
      • X fonts
      • Using Ghostscript fonts on X displays
      • X device parameters
    • SCO Unix
  • Command line options
    • General switches
      • Input control
      • File searching
      • Setting parameters
      • Suppress messages
    • Parameter switches (-d and -s)
      • Rendering parameters
      • Page parameters
      • Font-related parameters
      • Resource-related parameters
      • Interaction-related parameters
      • Device and output selection parameters
      • EPS parameters
      • Deferred Page Rendering
      • ICC color parameters
      • Other parameters
  • Improving performance
  • Summary of environment variables
  • Debugging
    • Debug Switches
    • Visual Trace
  • Appendix: Paper sizes known to Ghostscript
  • Appendix: X default font mappings
    • Standard X servers
      • Regular fonts
      • Symbol fonts
      • Dingbat fonts
    • Sun OpenWindows
  • Appendix: Running Ghostscript with third-partyfont renderers

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' paper.ps

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

ps2pdf file.ps
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 myfile.ps' you might use

gs -sDEVICE=epson myfile.ps

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
(myfile.ps) 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 -r XRES x YRES
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 -r res.

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 ABC.xyz, use

gs -sOutputFile=ABC.xyz

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/colorcir.ps
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:

            %[flags][width][.precision][l]type

    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:
-sOutputFile=ABC-%d.png
produces 'ABC-1.png', ... , 'ABC-10.png', ...

-sOutputFile=ABC-%03d.pgm
produces 'ABC-001.pgm', ... , 'ABC-010.pgm', ...

-sOutputFile=ABC_p%04d.tiff
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 (command.com or cmd.exe), youwill have to double the % character since the % is used bythat shell to prefix variables for substitution, e.g.,

gswin32c -sOutputFile=ABC%%03d.xyz
-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 somefile.ps to JPEG image files, one per page, use:

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

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
    -sPAPERSIZE=a4
    -sPAPERSIZE=legal
  • Otherwise you can set the page size using thepair of switches
    -dDEVICEWIDTHPOINTS= w -dDEVICEHEIGHTPOINTS= h
    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 gs_init.ps.This file is usually in the Resource/Init directory somewhere in the search path. See the section on finding files for details.

Find the line

% /DEFAULTPAPERSIZE (a4) def

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

/DEFAULTPAPERSIZE (a4) def

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 paper.ps.gz | 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
or
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

-dFirstPage= pagenumber
Begins interpreting on the designated page of the document.Pages of all documents in PDF collections are numbered sequentionally.
-dLastPage= pagenumber
Stops interpreting after the designated page of the document.Pages of all documents in PDF collections are numbered sequentionally.
-dPDFFitPage
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.

-dPrinted -dPrinted=false
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 an OutputFile parameter, and the printer options fordevices that do have this parameter.
-dUseBleedBox
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.
-dUseTrimBox
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.
-dUseArtBox
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.
-dUseCropBox
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.
-sPDFPassword= password
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).
-dShowAnnots=false
Don't enumerate anntoations associated with the page objects through Annots attribute. Annotations are shown by default.
-dShowAcroForm
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.
-dNoUserUnit
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.
-dRENDERTTNOTDEF
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:http://partners.adobe.com/public/developer/ps/index_specs.html

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值