• GhostScript

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

      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 common to convert a PostScript document to PDF:

      ps2pdf file.ps

      The output is saved as file.pdf.

      Selecting an output device

      -sDEVICE=device selects which output device. If this option isn’t given the default device is used. For complete description of the devices see the devices section of the documentation.

      gs -sDEVICE=epson myfile.ps

      you can also find out what devices are available by typing ‘devicenames ==‘ at the interactive prompt.

      (epson) selectdevice
      (myfile.ps) run

      Output resolution

      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

      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 actually begins 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 file upon exit, but changing the OutputFile device parameter will cause these devices to emit the pages received up to that point and then open the new file name given by OutputFile.

      For example, in order to create two PDF files from a single invocation of ghostscript 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 rasterizing figures, but sometimes you want images of each page of a multi-page document. You can tell Ghostscript to put each page of output in a series of similarly named files. To do this place a template ‘%d‘ in the filename which Ghostscript will replace with the page number.

      Note: Since the % character is used to precede the page number format specification, in order to represent a file name that contains a %, double % characters must be used. For example for the file my%foo the 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 format specifications. 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 extra blank page written (pdfwrite, ps2write, eps2write, pxlmono, pxlcolor, …).

      As noted above, when using MS Windows console (command.com or cmd.exe), you will have to double the % character since the % is used by that 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 output file 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 more input 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 its default page size. There are two ways to select other paper sizes from the command line:

      • If the desired paper size is listed in the section on paper sizes known to Ghostscript below, you can select it as the default paper size for a single invocation of Ghostscript by using the -sPAPERSIZE= switch, for instance:
        -sPAPERSIZE=a4
        -sPAPERSIZE=legal
      • Otherwise you can set the page size using the pair of switches:
        -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h 

        Where w be the desired paper width and h be the desired paper height in points (units of 1/72 of an inch).

      Individual documents can (and often do) specify a paper size, which takes precedence over the default size. To force a specific paper size and ignore the paper size specified in the document, select a paper size as just described, and also include the -dFIXEDMEDIA switch on the command line.

      The default set of paper sizes will be included in the currentpagedevice in the InputAttributes dictionary with each paper size as one of the entries. The last entry in the dictionary (which has numeric keys) is a non-standard (Ghostscript extension) type of PageSize where the array has four elements rather than the standard two elements. This four element array represents a page size range where the first two elements are the lower bound of the range and the second two are the upper bound. By default these are [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 sepcification for non-printer file formats such as JPEG, PNG, TIFF, EPS, …

      For actual printers, either the entire InputAttributes dictionary should be replaced or the range type entry should not be included. To simplify using the default page sizes in the InputAttributes dictionary, the command line option -dNORANGEPAGESIZE can be used. Using this option will result in automatic rotation of the document page if the requested page size matches one of the default page sizes.

      When the -dFIXEDMEDIA switch is given on the command line, the InputAttributes dictionary will only be populated with the single page size. This allows the -dPSFitPage option to fit the page size requested in a PostScript file to be rotated, scaled and centered for 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 change this to

      /DEFAULTPAPERSIZE (a4) def

      For a4 you can substitute any paper 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 be selected to be a4 or letter depending on the locale.

      Interacting with pipes

      As noted above, input files are normally specified on the command line. However, one can also "pipe" input into Ghostscript from another program 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 than going 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 -q switch to prevent Ghostscript from writing messages to standard output which become mixed with the intended output stream.

      Also, using the -sstdout=%stderr option is useful, particularly with input 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, the pdf2ps utility uses Ghostscript to convert PDF to (Level 2) PostScript.

      Switches for PDF files

      Here are some command line options specific to PDF

      -dNEWPDF From release 9.55.0 Ghostscript incorporates two complete PDF interpreters; the original long-standing interpreter is written in PostScript but there is now a new interpreter written in C.At present the old PostScript-based interpreter remains the default, in future releases the new C-based interpreter will become the default, though we would encourage people to experiment with the new interpreter and send us feedback. While there are two interpreters the command-line switch NEWPDF will allow selection of the existing interpreter when false and the new interpreter when true.
      -dPDFINFO Starting with release 9.56.0 this new switch will work with the PDF interpreter (GhostPDF) and with the PDF interpreter integrated into Ghostscript. When this switch is set the interpreter will emit information regarding the file, similar to that produced by the old pdf_info.ps program in the ‘lib’ folder.The format is not entirely the same, and the search for fonts and spot colours is ‘deeper’ than the old program; pdf_info.ps stops at the page level whereas the PDFINFO switch will descend into objects such as Forms, Images, type 3 fonts and Patterns. In addition different instances of fonts with the same name are now enumerated.
      Unlike the pdf_info.ps program there is no need to add the input file to the list of permitted files for reading (using --permit-file-read). 

      -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 have a 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 the file’s "screen" options. If neither of these is specified, the output will use the screen options for any output device that doesn’t have an OutputFile parameter, and the printer options for devices 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 be clipped when output in a production environment. This may include any extra bleed area needed to accommodate the physical limitations of cutting, folding, and trimming equipment. The actual printed page may 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 page after trimming. Some files have a TrimBox that is smaller than the MediaBox and may include white space, registration or cutting marks outside the CropBox. Using this option simulates appearance of the finished 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 useful when one wants to crop the page as much as possible without 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 a defined meaning, it simply provides a rectangle to which the page contents will be clipped (cropped). By convention, it is often, but not exclusively, used to aid the positioning of content on the (usually larger, in these cases) media.
      -sPDFPassword=password Sets the user or owner password to be used in decoding encrypted PDF files. For files created with encryption method 4 or earlier, the password is an arbitrary string of bytes; with encryption method 5 or later, it should be text in either UTF-8 or your locale’s character set (Ghostscript tries both).
      -dShowAnnots=false Don’t enumerate annotations associated with the page Annots key. Annotations are shown by default.In addition, finer control is available by defining an array /ShowAnnotTypes. Annotation types listed in this array will be drawn, whilst those not listed will not be drawn.
      To use this feature: -c "/ShowAnnotTypes [....] def" -f <input file> Where the array can contain one or more of the following names: /Stamp/Squiggly/Underline/Link/Text/Highlight/Ink/FreeText/StrikeOut and /stamp_dict.
      For example, adding the follow to the command line: -c "/ShowAnnotTypes [/Text /UnderLine] def" -f <input file> would draw only annotations with the subtypes "Text" and "UnderLine"
      -dShowAcroForm=false Don’t show annotations from the Interactive Form Dictionary (AcroForm dictionary). By default, AcroForm processing is now enabled because Adobe Acrobat does this. This option is provided to restore the previous behavior which corresponded to older Acrobat.
      -dNoUserUnit Ignore UserUnit parameter. This may be useful for backward compatibility with old versions of Ghostscript and Adobe Acrobat, or for processing files with large values of UserUnit that otherwise exceed implementation limits.
      -dRENDERTTNOTDEF If a glyph is not present in a font the normal behaviour is to use the /.notdef glyph instead. On TrueType fonts, this is often a hollow sqaure. Under some conditions Acrobat does not do this, instead leaving a gap equivalent to the width of the missing glyph, or the width of the /.notdef glyph if no /Widths array is present. Ghostscript now attempts to mimic this undocumented feature using a user parameter RenderTTNotdef. The PDF interpreter sets this user 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.

      These command line options are no longer specific to PDF, but have some specific differences with PDF files

      -dFirstPage=pagenumber Begin on the designated page of the document. Pages of all documents in PDF collections are numbered sequentionally.
      -dLastPage=pagenumber Stop after the designated page of the document. Pages of all documents in PDF collections are numbered sequentionally.
      -sPageList=pagenumber There are three possible values for this; even, odd or a list of pages to be processed. A list can include single pages or ranges of pages. Ranges of pages use the minus sign ‘-’, individual pages and ranges of pages are separated by commas ‘,’. A trailing minus ‘-’ means process all remaining pages. For example;
       

      -sPageList=1,3,5 indicates that pages 1, 3 and 5 should be processed.
      -sPageList=5-10 indicates that pages 5, 6, 7, 8, 9 and 10 should be processed.
      -sPageList=1,5-10,12- indicates that pages 1, 5, 6, 7, 8, 9, 10 and 12 onwards should be processed.

      Note: Use of PageList overrides FirstPage and/or LastPage, if you set these as well as PageList they will be ignored. The list of pages should be given in increasing order, you cannot process pages out of order and inserting higher numbered pages before lower numbered pages in the list will generate an error.

      The PDF interpreter and the other language interpreters handle these in slightly different ways. Because PDF files enable random access to pages in the document the PDF inerpreter only interprets and renders the required pages. PCL and PostScript cannot be handled in ths way, and so all the pages must be interpreted. However only the requested pages are rendered, which can still lead to savings in time. Be aware that using the ‘%d’ syntax for OutputFile does not reflect the page number in the original document. If you chose (for example) to process even pages by using -sPageList=even, then the output of -sOutputFile=out%d.png would still be out0.png, out1.png, out2.png etc……

      Because the PostScript and PCL interpreters cannot determine when a document terminates, sending multple files as input on the command line does not reset the PageList between each document, each page in the second and subsequent documents is treated as following on directly from the last page in the first document. The PDF interpreter, however, does not work this way. Since it knows about individual PDF files the PageList is applied to each PDF file separately. So if you were to set -sPageList=1,2 and then send two PDF files, the result would be pages 1 and 2 from the first file, and then pages 1 and 2 from the second file. The PostScript interpreter, by contrast, would only render pages 1 and 2 from the first file. This means you must exercise caution when using this switch, and probably should not use it at all when processing a mixture of PostScript and PDF files on the same command line.

      The XPS language like the PDF language allows random access to pages. The XPS interpreter handles all the PageList cases discussed above. It also handles cases such as:

      -sPageList=1,2,1,2 indicates repeated pages.  Pages processed in order 1, 2, 1, 2.
      -sPageList=10-5 indicates pages will be processed in the order 10, 9, 8, 7, 6, 5.
      -sPageList=1-,-1 indicates first processing from page 1 to end and then from end to page 1.

      In addition, the XPS interpreter allows the use of a -dLastPage < -dFirstPage. In this case the pages will be processed backwards from LastPage to FirstPage.

      Problems interpreting a PDF file

      Occasionally you may try to read or print a ‘PDF’ file that Ghostscript doesn’t recognize as PDF, even though the same file can be opened and interpreted by an Adobe Acrobat viewer. In many cases, this is because of incorrectly generated PDF. Acrobat tends to be very forgiving of invalid PDF files. Ghostscript tends to expect files to conform to the standard. For example, even though valid PDF files must begin with %PDF, Acrobat will scan the first 1000 bytes or so for this string, and ignore any preceding garbage.

      In the past, Ghostscript’s policy has been to simply fail with an error message when confronted with these files. This policy has, no doubt, encouraged PDF generators to be more careful. However, we now recognize that this behavior is not very friendly for people who just want to use Ghostscript to view or print PDF files. Our new policy is to try to render broken PDF’s, and also to print a warning, so that Ghostscript is still useful as a sanity-check for invalid files.

      PDF files from standard input

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

      How Ghostscript finds files

      When looking for initialization files (gs_*.pspdf_*.ps), font files, the Fontmap file, files named on the command line, and resource files, Ghostscript first tests whether the file 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 file using 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 -I switches in the command line, if any;
      3. The directories specified by the GS_LIB environment variable, if any;
      4. If built with COMPILE_INITS=1 (currently the default build) the files in the %rom%Resource/ and %rom%iccprofiles/ directories are built into the executable.
      5. The directories specified by the GS_LIB_DEFAULT macro (if any) in the makefile when this executable was built.

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

      Note that Ghostscript does not use this file searching algorithm for the run or file operators: for these operators, it simply opens the file with the name given. To run a file using the searching algorithm, 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 whether the value of the system parameter GenericResourceDir specifies an absolute path. The user may set it as explained in Resource-related parameters.

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

      If the value of the system parameter GenericResourceDir is 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 GenericResourceDir is not an absolute path, Ghostscript assumes multiple resource directories. In this case it concatenates :

      1. A directory listed in the section How 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 GenericResourceDir is the string ../Resource/ (or its equivalent in the file path syntax of the underlying platform), Ghostscript searches for ../Resource/CMap/Identity-H from all directories listed in How Ghostscript finds files. So in this example, if the user on a Windows platform specifies the command line option -I.;../gs/lib;c:/gs8.50/lib, Ghostscript searches for ../gs/Resource/CMap/Identity-H and then for c:/gs8.50/Resource/CMap/Identity-H.

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

      In the case of multiple resource directories, the default ResourceFileName procedure retrieves either a path to the first avaliable resource, or if the resource is not available it returns a path starting with GenericResourceDir. Consequently Postscript installers of Postscript resources will 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 the next section, it concatenates together

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

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

      General switches

      Input control

      @filename
      Causes Ghostscript to read filename and treat its contents the same as the command line. (This was intended primarily for getting around DOS’s 128-character limit on the length of a command line.) Switches or file 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 all remaining arguments (even if they have the syntactic form of switches) and defines the name ARGUMENTS in userdict (not systemdict) as an array of those strings, before running the file. When Ghostscript finishes executing the file, it exits back to the shell.
      -@ filename arg1 …
      Does the same thing as -- and -+, but expands @filename arguments.
      -
      -_
      These are not really switches: they tell Ghostscript to read from standard 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 for Ghostscript 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 that begins with "-" followed by a non-digit, or with "@". For example, if the file quit.ps contains just the word "quit", then -c quit on the command line is equivalent to quit.ps there. Each argument must be valid PostScript, either individual tokens as defined by the token operator, or a string containing valid PostScript.Because Ghostscript must initialize the PostScript environment before executing the commands specified by this option it should be specified after other setup options. Specifically this option ‘bind’s all operations and sets the systemdict to readonly. 

      -f Interprets following non-switch arguments as file names to be executed using the normal run command. Since this is the default behavior, -f is useful only for terminating the list of tokens for the -c switch.
      -ffilename 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 using the search rule under "How Ghostscript finds files" above: Ghostscript’s own initialization files, fonts, and files named on the command line.

      -Idirectories
      -I directories
      Adds the designated list of directories at the head of the search path for library files.
      -P
      Makes Ghostscript look first in the current directory for library files.
      -P-
      Makes Ghostscript not look first in the current directory for library files (unless, of course, the first explicitly supplied directory is "."). This is now the default.

      Setting parameters

      -Dname
      -dname
      Define a name in systemdict with value=true.
      -Dname=token
      -dname=token
      Define a name in systemdict with the given value. The value must be a 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 in systemdict, so any name that that conflicts with one usually in systemdict will be replaced by the normal definition during the interpreter initialization.
      -Sname=string
      -sname=string
      Define a name in systemdict with a given string as value. This is different from -d. For example, -dXYZ=35 on the command line is equivalent to the program fragment
      /XYZ 35 def 

      whereas -sXYZ=35 is equivalent to
      /XYZ (35) def

      -pname=string
      Define a name in systemdict with the parsed version of the given string as value. The string takes a parameter definition in (something very close to) postscript format. This allows more complex structures to be passed in than is possible with -d or -s. For example:
      -pFoo="<< /Bar[1 2 3]/Baz 0.1 /Whizz (string) /Bang <0123> >>" 

      This means that -p can do the job of both -d and -s. For example:
      -dDownScaleFactor=3

      can be equivalently performed by
      -pDownScaleFactor=3

      and
      -sPAPERSIZE=letter

      can be equivalently performed by
      -pPAPERSIZE="(letter)"

      Note, that there are some ‘special’ values that should be set using -s, not -p, such as DEVICE and DefaultGrayProfile. Broadly, only use -p if you cannot set what you want using -s or -d.

      Also, internally, after setting an parameter with -p we perform an initgraphics operation. This is required to allow changes in parameters such as HWResolution to take effect. This means that attempting to use -p other than at the start of a page is liable to give unexpected results.

      -uname
      Un-define a name, cancelling -d or -s.Note that the initialization file gs_init.ps makes systemdict read-only, so the values of names defined with -D-d-S, and -s cannot be changed -- although, of course, they can be superseded by definitions in userdict or other dictionaries. However, device parameters set this way (PageSizeMargins, etc.) are not read-only, and can be changed by code in PostScript files. 

      -gnumber1xnumber2
      Equivalent to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2, specifying the device width and height in pixels for the benefit of devices such as X11 windows and 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 (same as -rnumberxnumber)
      -rnumber1xnumber2
      Equivalent to -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLUTION=number2, specifying the device horizontal and vertical resolution in pixels per inch for the benefit of devices such as printers that support multiple X and Y resolutions.

      Suppress messages

      -q
      Quiet startup: suppress normal startup messages, and also do the equivalent of -dQUIET.

      Parameter switches (-d and -s)

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

      Rendering parameters

      -dCOLORSCREEN
      -dCOLORSCREEN=0
      -dCOLORSCREEN=false
      On high-resolution devices (at least 150 dpi resolution, or -dDITHERPPI specified), -dCOLORSCREEN forces the use of separate halftone screens with different angles for CMYK or RGB if halftones are needed (this produces the best-quality output); -dCOLORSCREEN=0 uses separate screens with the same frequency and angle; -dCOLORSCREEN=false forces the use of a single binary screen. The default if COLORSCREEN is not specified is to use separate screens with different angles if the device has fewer than 5 bits per color, and a single binary screen (which is never actually used under normal circumstances) on all other devices.
      -dDITHERPPI=lpi
      Forces all devices to be considered high-resolution, and forces use of a halftone screen or screens with lpi lines per inch, disregarding the actual device resolution. Reasonable values for lpi are N/5 to N/20, where N is the resolution in dots per inch.
      -dInterpolateControl=control_value
      This allows control of the image interpolation.By default InterpolateControl is 1 and the image rendering for images that have /Interpolate true are interpolated to the full device resolution. Otherwise, images are rendered using the nearest neighbour scaling (Bresenham’s line algorithm through the image, plotting the closest texture coord at each pixel). When downscaling this results in some source pixels not appearing at all in the destination. When upscaling, each source pixels will cover at least one destination pixel. 

      When the control_value is 0 no interpolation is performed, whether or not the file has images with /Interpolate true.

      When the control_value is greater than 1 interpolation is performed for images with /Interpolate true as long as the image scaling factor on either axis is larger than the control_value. Also, the interpolation only produces images that have (device resolution / control_value) maximum resolution rather than full device resolution. This allows for a performance vs. quality tradeoff since the number of pixels produced by the interpolation will be a fraction of the interpolated pixels at full device resolution. Every source pixel will contribute partially to the destination pixels.

      When the InterpolateControl control_value is less than 0 interpolation is forced as if all images have /Interpolate true, and the interpolation is controlled by the absolute value of the control_value as described above. Thus, -dInterpolateControl=-1 forces all images to be interpolated at full device resolution.

      Computationally, image interpolatt ory is specified on the command line using -sICCProfilesDir=, that directory is searched before the iccprofiles/ directory of the ROM file system is searched.

      A note for Windows users, Artifex recommends the use of the forward slash delimiter due to the special interpretation of \" by the Microsoft C startup code. See Parsing C Command-Line Arguments for more information.

      Other parameters

      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\
      
          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, the relevant section of the resource file should look like this:


      Running Ghostscript with third-party font renderers

      Font API (FAPI) is a feature which allows to attach third-party font renderers to Ghostscript. This section explains how to run Ghostscript with third-party font renderers, such as UFST. NOTE: FreeType is now the default font renderer for 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 incompatible with devices that can embed fonts in their output (such as pdfwrite), because such renderers may store fonts in a form from which Ghostscript cannot get the necessary information for embedding, for example, the Microtype fonts supplied with the UFST. Ghostscript can be configured to disable such renderers when such a device is being used.

      As of Ghostscript version 9.0, Ghostscript uses Freetype 2.4.x as the default font scaler/renderer.

      With this change, we added a new switch:-dDisableFAPI=true to revert to the older behavior, 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 has proven itself robust and reliable in the "real world".

      NOTE: With version 9.18 recently released we have, for some time, regarded FAPI/Freetype as being the canonical glyph rendering solution for Ghostscript and associated products, and the non-FAPI rendering to be deprecated. As such, the -dDisableFAPI=true option is also considered deprecated, and should be expected to be removed shortly after the next release.

      To run Ghostscript with UFST, you first need to build Ghostscript with 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 substitute any FAPI-handled font to a resident PostScript font, using special map files FAPIfontmap and FAPIcidfmap. Second, you can redirect PostScript fonts to FAPI, setting entries in FAPIconfig file.

      Names FAPIfontmapFAPIcidfmapFAPIconfig in 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 in How 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 and with 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 records and 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 PostScript documents use to access the font, which may differ from 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 integer 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 records must 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 name is 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 of Font category. CID fonts to be listed in another map file.

      Ghostscript distribution includes sample map files gs/lib/FAPIfontmapgs/lib/FCOfontmap-PCLPS2gs/lib/FCOfontmap-PCLPS3gs/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 for CIDFont 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 :

 

Aucun commentaire

 

Laissez un commentaire