You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 KiB

The Ghostscript Imposition

Imposition is one of the fundamental steps in the prepress printing process. It consists of the arrangement of the printed products pages on the printers sheet, in order to obtain faster printing, simplify binding and reduce paper waste.

Correct imposition minimizes printing time by maximizing the number of pages per impression, reducing cost of press time and materials. To achieve this, the printed sheet must be filled as fully as possible.

https://en.wikipedia.org/wiki/Imposition

Paged media: A timeline

1980s

1990s

Dave Raggett's Touch of Style tutorial from/updated 2002, is a good introduction to and reflection on using CSS for the web -- notice there's almost no discussion of print -- it's all about how pages get rendered online, aka in a web browser. This is still the focus of CSS today... but...

TODAY

https://en.wikipedia.org/wiki/CSS

CSS3 includes an extensive Paged Media Specification describing how CSS can be also used to render "paged media" (ie when printed or saved as PDF). Most browsers do not implement these rules (except in some cases when you print a page). The Weasyprint python library implements some of these guidelines.

The "UNIX" philosophy of small tools composed together (and the pipeline)

Use the !shell

Jupyter (and ipython before it) supports the use of shell commands fluidly along side your python code. When the line starts with a ! (the exclamation point, often called bang by command line users), the command is interpreted as a shell command and performed, the results displayed below, just like with python code. Note that the shell has different rules about what a good structure is. In any case the first word is the name of a command...

In [1]:
!date
Wed 28 Oct 2020 09:10:50 PM CET
In [2]:
!whoami
mb
In [3]:
!ls
aalib-pdf.ipynb			   nltk-tfidf.ipynb
ASCII-canvas-to-PDF.ipynb	   patches
ASCII-canvas-to-PDF.pdf		   patterns-generating.ipynb
ASCII-patch-making.ipynb	   patterns-searching-for.ipynb
ASCII-quilt.ipynb		   PIL-basics.ipynb
ASCII-quilt-making.ipynb	   pillow_imagedraw.ipynb
ASCII-QUILT.pdf			   py
Concordance_Patches		   python-cheatsheet.ipynb
concordance_quilt.ipynb		   quilt.ipynb
dictionary-step-by-step.ipynb	   quilts
fonts				   reportlab-canvas-A4-bag-of-words.ipynb
hotseat.ipynb			   reportlab-canvas-A4-bag-of-words.pdf
img				   reportlab-cheatsheet.ipynb
json-dataset.json		   reportlab_tests.ipynb
json-making-datasets.ipynb	   TheGhostscriptImposition.ipynb
mydocument.pdf			   txt
nltk-frequency-distribution.ipynb  untitled.txt
NLTKing.ipynb			   weasyprint.ipynb
nltk-pos-tagger.ipynb		   weasyprint-test.pdf
nltk-similar-words.ipynb	   WordNet-synsets.ipynb

An zine introduction to the terminal

https://solarpunk.cool/zines/map-is-the-territory/

MAN oh MAN

A very important concept from the UNIX / Linux / Libre software world is that documentation ought to be seen as an full part of the distribution of software. When software is installed, it often installs a so-called "man page" (for manual). You can then read the manual with the "man" command followed by the command you are interested in...

In [4]:
!man gs
GS(1)                             Ghostscript                            GS(1)

NAME
       gs  -  Ghostscript  (PostScript  and  PDF language interpreter and pre
       viewer)

SYNOPSIS
       gs [ options ] [ files ] ...

DESCRIPTION
       The gs command invokes Ghostscript, an interpreter  of  Adobe  Systems'
       PostScript(tm)  and Portable Document Format (PDF) languages.  gs reads
       "files" in sequence and executes them as  Ghostscript  programs.  After
       doing this, it reads further input from the standard input stream (nor
       mally the keyboard), interpreting each line separately and output to an
       output  device (may be a file or an X11 window preview, see below). The
       interpreter exits gracefully when it encounters the "quit" command (ei
       ther  in  a file or from the keyboard), at end-of-file, or at an inter
       rupt signal (such as Control-C at the keyboard).

       The interpreter recognizes many option switches, some of which are  de
       scribed below. Please see the usage documentation for complete informa
       tion. Switches may appear anywhere in the command line and apply to all
       files  thereafter.   Invoking Ghostscript with the -h or -? switch pro
       duces a message which shows several useful switches,  all  the  devices
       known  to  that  executable,  and the search path for fonts; on Unix it
       also shows the location of detailed documentation.

       Ghostscript may be built to use many different output devices.  To  see
       which devices your executable includes, run "gs -h".

       Unless  you specify a particular device, Ghostscript normally opens the
       first one of those and directs output to it.

       If you have installed the ghostscript-x Debian package and are under X,
       the  default device is an X11 window (previewer), else ghostscript will
       use the bbox device and print on stdout the dimension of the postscript
       file.

       So  if the first one in the list is the one you want to use, just issue
       the command

            gs myfile.ps

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

            devicenames ==

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

            -sDEVICE=AbcXyz

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

            gs -sDEVICE=epson myfile.ps

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

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

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

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

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

            gs -sDEVICE=epson -r60x72

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

            gs -sDEVICE=epson -r240x72.

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

            -sOutputFile=foo.xyz

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

            -sOutputFile=foo%d.xyz

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

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

            -sOutputFile=%pipe%lpr

       You can also send output to standard output:

            -sOutputFile=-
       or
            -sOutputFile=%stdout%

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

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

            -sPAPERSIZE=<paper_size>

       for instance

            -sPAPERSIZE=a4
       or
            -sPAPERSIZE=legal

       Most ISO and US paper sizes are recognized. See the usage documentation
       for  a  full  list,  or  the  definitions  in  the  initialization file
       "gs_statd.ps".

       Ghostscript can do many things other than print or view PostScript  and
       PDF  files.   For  example,  if  you want to know the bounding box of a
       PostScript (or EPS) file, Ghostscript provides a special "device"  that
       just prints out this information.

       For  example,  using  one  of the example files distributed with Ghost
       script,

            gs -sDEVICE=bbox golfer.ps

       prints out

            %%BoundingBox: 0 25 583 732
            %%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445

OPTIONS
       -- 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.

       -Dname=token
       -dname=token
              Define  a  name  in "systemdict" with the given definition.  The
              token must be exactly one token (as defined by the "token" oper
              ator) and may contain no whitespace.

       -Dname
       -dname Define a name in "systemdict" with value=null.

       -Sname=string
       -sname=string
              Define  a  name  in  "systemdict"  with a given string as value.
              This is different from -d.  For example, -dname=35 is equivalent
              to the program fragment
                   /name 35 def
              whereas -sname=35 is equivalent to
                   /name (35) def

       -P     Makes Ghostscript to look first in the current directory for li
              brary files.  By default, Ghostscript no  longer  looks  in  the
              current  directory, unless, of course, the first explicitly sup
              plied directory is "." in -I.  See also the INITIALIZATION FILES
              section  below,  and  bundled Use.htm for detailed discussion on
              search paths and how Ghostcript finds files.

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

       -gnumber1xnumber2
              Equivalent  to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2.
              This is for the benefit of devices (such as  X11  windows)  that
              require (or allow) width and height to be specified.

       -rnumber
       -rnumber1xnumber2
              Equivalent  to  -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLU
              TION=number2.  This is for the benefit of devices such as print
              ers that support multiple X and Y resolutions.  If only one num
              ber is given, it is used for both X and Y resolutions.

       -Idirectories
              Adds the designated list of  directories  at  the  head  of  the
              search path for library files.

       -      This  is  not really a switch, but indicates to Ghostscript that
              standard input is coming from a file or a pipe and not  interac
              tively  from  the command line.  Ghostscript reads from standard
              input until it reaches end-of-file, executing it like any  other
              file, and then continues with processing the command line.  When
              the command line has been entirely processed, Ghostscript  exits
              rather than going into its interactive mode.

       Note  that  the  normal initialization file "gs_init.ps" makes "system
       dict" read-only, so the values of names defined with -D, -d, -S, or  -s
       cannot be changed (although, of course, they can be superseded by defi
       nitions in "userdict" or other dictionaries.)

SPECIAL NAMES
       -dNOCACHE
              Disables character caching.  Useful only for debugging.

       -dNOBIND
              Disables the "bind" operator.  Useful only for debugging.

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

       -dNOPAUSE
              Disables the prompt and pause at the end of each page.  This may
              be desirable for applications where another program  is  driving
              Ghostscript.

       -dNOPLATFONTS
              Disables  the  use  of fonts supplied by the underlying platform
              (for instance X Windows). This may be  needed  if  the  platform
              fonts look undesirably different from the scalable fonts.

       -dSAFER
              Restricts  file operations the job can perform.  Strongly recom
              mended for spoolers, conversion scripts or other sensitive envi
              ronments  where  a badly written or malicious PostScript program
              code must be prevented from changing important files.

       -dWRITESYSTEMDICT
              Leaves "systemdict" writable.  This is  necessary  when  running
              special  utility programs, but is strongly discouraged as it by
              passes normal Postscript security measures.

       -sDEVICE=device
              Selects an alternate initial output device, as described above.

       -sOutputFile=filename
              Selects an alternate output file (or pipe) for the initial  out
              put device, as described above.

SAFER MODE
       The -dSAFER option disables the "deletefile" and "renamefile" operators
       and prohibits opening piped commands ("%pipe%cmd"). Only "%stdout"  and
       "%stderr"  can  be  opened  for  writing. It also disables reading from
       files, except for "%stdin", files given as a command line argument, and
       files  contained in paths given by LIBPATH and FONTPATH or specified by
       the system params /FontResourceDir and /GenericResourceDir.

       This mode also sets the .LockSafetyParams parameter of the initial out
       put  device  to protect against programs that attempt to write to files
       using the OutputFile device  parameter.  Since  the  device  parameters
       specified  on  the command line, including OutputFile, are set prior to
       SAFER mode, use of "-sOutputFile=..." on  the  command  line  is  unre
       stricted.

       SAFER mode prevents changing the /GenericResourceDir, /FontResourceDir,
       /SystemParamsPassword, and /StartJobPassword.

       While SAFER mode is not the default, it is the default for many wrapper
       scripts  such  as ps2pdf and may be the default in a subsequent release
       of Ghostscript.  Thus when running programs that need to open files  or
       set  restricted  parameters  you should pass the -dNOSAFER command line
       option or its synonym -dDELAYSAFER.

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

FILES
       The  locations of many Ghostscript run-time files are compiled into the
       executable when it is built.  Run "gs  -h"  to  find  the  location  of
       Ghostscript  documentation  on your system, from which you can get more
       details. On a Debian system they are in /usr.

       /usr/share/ghostscript/[0-9]*.[0.9]*/*
              Startup files, utilities,  and  basic  font  definitions  (where
              [0-9]*.[0.9]* is the ghostscript version)

       /usr/share/fonts/type1/gsfonts/*
              More font definitions from the gsfonts package

       /usr/share/doc/ghostscript/examples/*
              Ghostscript  demonstration  files (if ghostscript-doc package is
              installed)

       /usr/share/doc/ghostscript/*
              Diverse document files  (may  need  to  install  ghostscript-doc
              package)

INITIALIZATION FILES
       When  looking for the initialization files "gs_*.ps", the files related
       to fonts, or the file for the "run" operator, Ghostscript  first  tries
       to  open the file with the name as given, using the current working di
       rectory if no directory is specified.  If this fails, and the file name
       doesn't  specify  an explicit directory or drive (for instance, doesn't
       contain "/" on Unix systems), Ghostscript tries directories in this or
       der:

       1.  the  directories  specified  by the -I switches in the command line
           (see below), if any;

       2.  the directories specified by the GS_LIB  environment  variable,  if
           any;

       3.  the directories specified by the GS_LIB_DEFAULT macro in the Ghost
           script makefile when the executable was built.   GS_LIB_DEFAULT  is
           "/usr/share/ghostscript/[0-9]*.[0-9]*/lib" on a Debian system where
           "[0-9]*.[0-9]*" represents the Ghostscript version number

       Each of these (GS_LIB_DEFAULT, GS_LIB, and -I parameter) may be  either
       a single directory or a list of directories separated by ":".

ENVIRONMENT
       GS_OPTIONS
              String  of  options  to be processed before the command line op
              tions

       GS_DEVICE
              Used to specify an output device

       GS_FONTPATH
              Path names used to search for fonts

       GS_LIB Path names for initialization files and fonts

       TEMP   Where temporary files are made

X RESOURCES
       Ghostscript, or more properly the X11 display  device,  looks  for  the
       following resources under the program name "Ghostscript":

       borderWidth
              The border width in pixels (default = 1).

       borderColor
              The name of the border color (default = black).

       geometry
              The window size and placement, WxH+X+Y (default is NULL).

       xResolution
              The  number  of  x  pixels  per  inch  (default is computed from
              WidthOfScreen and WidthMMOfScreen).

       yResolution
              The number of y  pixels  per  inch  (default  is  computed  from
              HeightOfScreen and HeightMMOfScreen).

       useBackingPixmap
              Determines  whether  backing store is to be used for saving dis
              play window (default = true).

       See the usage document for a more complete list of resources.   To  set
       these  resources on Unix, put them in a file such as "~/.Xresources" in
       the following form:

            Ghostscript*geometry:     612x792-0+0
            Ghostscript*xResolution: 72
            Ghostscript*yResolution: 72

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

            % xrdb -merge ~/.Xresources

SEE ALSO
       The various Ghostscript document files (above), especially Use.htm.  On
       Debian you may need to install ghostscript-doc before reading the docu
       mentation.

BUGS
       See   http://bugs.ghostscript.com/   and   the   Usenet   news    group
       comp.lang.postscript.

VERSION
       This document was last revised for Ghostscript version 9.27.

AUTHOR
       Artifex  Software,  Inc.  are  the  primary maintainers of Ghostscript.
       Russell J. Lang, gsview at ghostgum.com.au, is the author  of  most  of
       the MS Windows code in Ghostscript.

9.27                             4 April 2019                            GS(1)

If you read the manual on the man command itself (type man man)... You see it supports different output formats. The -t option outputs in the Postscript language.

In [5]:
!man -t gs
%!PS-Adobe-3.0
%%Creator: groff version 1.22.4
%%CreationDate: Wed Oct 28 20:11:56 2020
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Times-Italic
%%DocumentSuppliedResources: procset grops 1.22 4
%%Pages: 6
%%PageOrder: Ascend
%%DocumentMedia: Default 595 842 0 () ()
%%Orientation: Portrait
%%EndComments
%%BeginDefaults
%%PageMedia: Default
%%EndDefaults
%%BeginProlog
%%BeginResource: procset grops 1.22 4
%!PS-Adobe-3.0 Resource-ProcSet
/setpacking where{
pop
currentpacking
true setpacking
}if
/grops 120 dict dup begin
/SC 32 def
/A/show load def
/B{0 SC 3 -1 roll widthshow}bind def
/C{0 exch ashow}bind def
/D{0 exch 0 SC 5 2 roll awidthshow}bind def
/E{0 rmoveto show}bind def
/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
/G{0 rmoveto 0 exch ashow}bind def
/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/I{0 exch rmoveto show}bind def
/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
/K{0 exch rmoveto 0 exch ashow}bind def
/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/M{rmoveto show}bind def
/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
/O{rmoveto 0 exch ashow}bind def
/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/Q{moveto show}bind def
/R{moveto 0 SC 3 -1 roll widthshow}bind def
/S{moveto 0 exch ashow}bind def
/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/SF{
findfont exch
[exch dup 0 exch 0 exch neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/MF{
findfont
[5 2 roll
0 3 1 roll
neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/level0 0 def
/RES 0 def
/PL 0 def
/LS 0 def
/MANUAL{
statusdict begin/manualfeed true store end
}bind def
/PLG{
gsave newpath clippath pathbbox grestore
exch pop add exch pop
}bind def
/BP{
/level0 save def
1 setlinecap
1 setlinejoin
DEFS/BPhook known{DEFS begin BPhook end}if
72 RES div dup scale
LS{
90 rotate
}{
0 PL translate
}ifelse
1 -1 scale
}bind def
/EP{
level0 restore
showpage
}def
/DA{
newpath arcn stroke
}bind def
/SN{
transform
.25 sub exch .25 sub exch
round .25 add exch round .25 add exch
itransform
}bind def
/DL{
SN
moveto
SN
lineto stroke
}bind def
/DC{
newpath 0 360 arc closepath
}bind def
/TM matrix def
/DE{
TM currentmatrix pop
translate scale newpath 0 0 .5 0 360 arc closepath
TM setmatrix
}bind def
/RC/rcurveto load def
/RL/rlineto load def
/ST/stroke load def
/MT/moveto load def
/CL/closepath load def
/Fr{
setrgbcolor fill
}bind def
/setcmykcolor where{
pop
/Fk{
setcmykcolor fill
}bind def
}if
/Fg{
setgray fill
}bind def
/FL/fill load def
/LW/setlinewidth load def
/Cr/setrgbcolor load def
/setcmykcolor where{
pop
/Ck/setcmykcolor load def
}if
/Cg/setgray load def
/RE{
findfont
dup maxlength 1 index/FontName known not{1 add}if dict begin
{
1 index/FID ne
2 index/UniqueID ne
and
{def}{pop pop}ifelse
}forall
/Encoding exch def
dup/FontName exch def
currentdict end definefont pop
}bind def
/DEFS 0 def
/EBEGIN{
moveto
DEFS begin
}bind def
/EEND/end load def
/CNT 0 def
/level1 0 def
/PBEGIN{
/level1 save def
translate
div 3 1 roll div exch scale
neg exch neg exch translate
0 setgray
0 setlinecap
1 setlinewidth
0 setlinejoin
10 setmiterlimit
[]0 setdash
/setstrokeadjust where{
pop
false setstrokeadjust
}if
/setoverprint where{
pop
false setoverprint
}if
newpath
/CNT countdictstack def
userdict begin
/showpage{}def
/setpagedevice{}def
mark
}bind def
/PEND{
cleartomark
countdictstack CNT sub{end}repeat
level1 restore
}bind def
end def
/setpacking where{
pop
setpacking
}if
%%EndResource
%%EndProlog
%%BeginSetup
%%BeginFeature: *PageSize Default
<< /PageSize [ 595 842 ] /ImagingBBox null >> setpagedevice
%%EndFeature
%%IncludeResource: font Times-Roman
%%IncludeResource: font Times-Bold
%%IncludeResource: font Times-Italic
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron
/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
/Times-Roman@0 ENC0/Times-Roman RE
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 184.005(GS\(1\) Ghostscript GS\(1\))72 48 R/F1
10.95/Times-Bold@0 SF -.219(NA)72 84 S(ME).219 E F0
(gs \255 Ghostscript \(PostScript and PDF language interpreter and pre)
108 96 Q(vie)-.25 E(wer\))-.25 E F1(SYNOPSIS)72 112.8 Q/F2 10
/Times-Bold@0 SF(gs)108 124.8 Q F0([)2.5 E/F3 10/Times-Italic@0 SF
(options)2.5 E F0 2.5(][)2.5 G F3(\214les)A F0 2.5(].)2.5 G(..)-2.5 E F1
(DESCRIPTION)72 141.6 Q F0(The)108 153.6 Q F2(gs)4.175 E F0 1.675
(command in)4.175 F -.2(vo)-.4 G -.1(ke).2 G(s).1 E F2(Ghostscript)4.175
E F0 4.175(,a)C 4.175(ni)-4.175 G 1.675(nterpreter of Adobe Systems')
-4.175 F F2 -.2(Po)4.175 G(stScript).2 E F0 1.675(\(tm\) and)B F2 -.2
(Po)4.175 G(rtable).2 E .875(Document F)108 165.6 R(ormat)-.25 E F0 .875
(\(PDF\) languages.)3.375 F F2(gs)5.875 E F0 .875
(reads "\214les" in sequence and e)3.375 F -.15(xe)-.15 G .875
(cutes them as Ghostscript pro-).15 F .071(grams. After doing this, it \
reads further input from the standard input stream \(normally the k)108
177.6 R -.15(ey)-.1 G .07(board\), inter).15 F(-)-.2 E .693
(preting each line separately and output to an output de)108 189.6 R
.694(vice \(may be a \214le or an X11 windo)-.25 F 3.194(wp)-.25 G(re)
-3.194 E(vie)-.25 E 1.994 -.65(w, s)-.25 H(ee).65 E(belo)108 201.6 Q
.353(w\). The interpreter e)-.25 F .352(xits gracefully when it encount\
ers the "quit" command \(either in a \214le or from the)-.15 F -.1(ke)
108 213.6 S(yboard\), at end-of-\214le, or at an interrupt signal \(suc\
h as Control-C at the k)-.05 E -.15(ey)-.1 G(board\).).15 E .414
(The interpreter recognizes man)108 230.4 R 2.914(yo)-.15 G .414
(ption switches, some of which are described belo)-2.914 F 1.714 -.65
(w. P)-.25 H .414(lease see the usage).65 F .139
(documentation for complete information. Switches may appear an)108
242.4 R .138(ywhere in the command line and apply to)-.15 F .188
(all \214les thereafter)108 254.4 R 5.188(.I)-.55 G -1.9 -.4(nv o)-5.188
H .189(king Ghostscript with the).4 F F2<ad68>2.689 E F0(or)2.689 E F2
<ad3f>2.689 E F0 .189(switch produces a message which sho)2.689 F .189
(ws se)-.25 F -.15(ve)-.25 G(ral).15 E 1.302
(useful switches, all the de)108 266.4 R 1.301(vices kno)-.25 F 1.301
(wn to that e)-.25 F -.15(xe)-.15 G 1.301
(cutable, and the search path for fonts; on Unix it also).15 F(sho)108
278.4 Q(ws the location of detailed documentation.)-.25 E .891
(Ghostscript may be b)108 295.2 R .892(uilt to use man)-.2 F 3.392(yd)
-.15 G(if)-3.392 E .892(ferent output de)-.25 F 3.392(vices. T)-.25 F
3.392(os)-.8 G .892(ee which de)-3.392 F .892(vices your e)-.25 F -.15
(xe)-.15 G .892(cutable in-).15 F(cludes, run ")108 307.2 Q F2(gs -h)A
F0(".)A .37(Unless you specify a particular de)108 324 R .37(vice, Ghos\
tscript normally opens the \214rst one of those and directs output)-.25
F(to it.)108 336 Q .572(If you ha)108 352.8 R .872 -.15(ve i)-.2 H .572
(nstalled the ghostscript-x Debian package and are under X, the def).15
F .572(ault de)-.1 F .573(vice is an X11 win-)-.25 F(do)108 364.8 Q
3.399(w\()-.25 G(pre)-3.399 E(vie)-.25 E .898
(wer\), else ghostscript will use the bbox de)-.25 F .898
(vice and print on stdout the dimension of the post-)-.25 F
(script \214le.)108 376.8 Q
(So if the \214rst one in the list is the one you w)108 393.6 Q
(ant to use, just issue the command)-.1 E(gs my\214le.ps)144 410.4 Q
-1.1(Yo)108 427.2 S 2.5(uc)1.1 G(an also check the set of a)-2.5 E -.25
(va)-.2 G(ilable de).25 E(vices from within Ghostscript: in)-.25 E -.2
(vo)-.4 G .2 -.1(ke G).2 H(hostscript and type).1 E(de)144 444 Q
(vicenames ==)-.25 E -.2(bu)108 460.8 S 2.802(tt).2 G .302
(he \214rst de)-2.802 F .302
(vice on the resulting list may not be the def)-.25 F .302(ault de)-.1 F
.302(vice you determine with ")-.25 F F2 .302(gs -h)B F0 2.802(". T)B
2.802(os)-.8 G(pec-)-2.802 E(ify "AbcXyz" as the initial output de)108
472.8 Q(vice, include the switch)-.25 E(\255sDEVICE=AbcXyz)144 489.6 Q
-.15(Fo)108 506.4 S 2.5(re).15 G
(xample, for output to an Epson printer you might use the command)-2.65
E(gs \255sDEVICE=epson my\214le.ps)144 523.2 Q .746(The "\255sDEVICE=" \
switch must precede the \214rst mention of a \214le to print, and only \
the switch')108 540 R 3.245<738c>-.55 G .745(rst use)-3.245 F(has an)108
552 Q 2.5(ye)-.15 G -.25(ff)-2.5 G(ect.).25 E(Finally)108 568.8 Q 3.452
(,y)-.65 G .952(ou can specify a def)-3.452 F .953(ault de)-.1 F .953
(vice in the en)-.25 F .953(vironment v)-.4 F(ariable)-.25 E F2
(GS_DEVICE)3.453 E F0 5.953(.T)C .953(he order of prece-)-5.953 F .637
(dence for these alternati)108 580.8 R -.15(ve)-.25 G 3.137(sf).15 G
.636(rom highest to lo)-3.137 F .636(west \(Ghostscript uses the de)-.25
F .636(vice de\214ned highest in the list\))-.25 F(is:)108 592.8 Q .473
(Some de)108 609.6 R .473(vices can support dif)-.25 F .473
(ferent resolutions \(densities\).)-.25 F 2.073 -.8(To s)5.473 H .474
(pecify the resolution on such a printer).8 F 2.974(,u)-.4 G(se)-2.974 E
(the "\255r" switch:)108 621.6 Q(gs \255sDEVICE=<de)144 638.4 Q
(vice> \255r<xres>x<yres>)-.25 E -.15(Fo)108 655.2 S 2.5(re).15 G
(xample, on a 9-pin Epson-compatible printer)-2.65 E 2.5(,y)-.4 G
(ou get the lo)-2.5 E(west-density \(f)-.25 E(astest\) mode with)-.1 E
(gs \255sDEVICE=epson \255r60x72)144 672 Q
(and the highest-density \(best output quality\) mode with)108 688.8 Q
(gs \255sDEVICE=epson \255r240x72.)144 705.6 Q .478
(If you select a printer as the output de)108 722.4 R .478
(vice, Ghostscript also allo)-.25 F .477
(ws you to choose where Ghostscript sends)-.25 F 188.445(9.27 4)72 768 R
(April 2019)2.5 E(1)203.445 E 0 Cg EP
%%Page: 2 2
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 184.005(GS\(1\) Ghostscript GS\(1\))72 48 R .544
(the output \255\255 on Unix systems, usually to a temporary \214le.)108
84 R 2.144 -.8(To s)5.544 H .544
(end the output to a \214le "foo.xyz", use the).8 F(switch)108 96 Q
(\255sOutputFile=foo.xyz)144 112.8 Q -1.1(Yo)108 129.6 S 3.644(um)1.1 G
1.144(ight w)-3.644 F 1.144(ant to print each page separately)-.1 F
6.144(.T)-.65 G 3.644(od)-6.944 G 3.644(ot)-3.644 G 1.143
(his, send the output to a series of \214les "foo1.xyz,)-3.644 F(foo2.x\
yz, ..." using the "\255sOutputFile=" switch with "%d" in a \214lename \
template:)108 141.6 Q(\255sOutputFile=foo%d.xyz)144 158.4 Q .004
(Each resulting \214le recei)108 175.2 R -.15(ve)-.25 G 2.504(so).15 G
.005(ne page of output, and the \214les are numbered in sequence.)-2.504
F .005("%d" is a printf for)5.005 F(-)-.2 E
(mat speci\214cation; you can also use a v)108 187.2 Q(ariant lik)-.25 E
2.5(e")-.1 G(%02d".)-2.5 E -1.1(Yo)108 204 S 3.385(uc)1.1 G .885
(an also send output to a pipe.)-3.385 F -.15(Fo)5.885 G 3.385(re).15 G
.885(xample, to pipe output to the ")-3.535 F/F1 10/Times-Bold@0 SF(lpr)
A F0 3.384("c)C .884(ommand \(which, on man)-3.384 F(y)-.15 E
(Unix systems, directs it to a printer\), use the option)108 216 Q
(\255sOutputFile=%pipe%lpr)144 232.8 Q -1.1(Yo)108 249.6 S 2.5(uc)1.1 G
(an also send output to standard output:)-2.5 E(\255sOutputFile=\255)144
266.4 Q(or)108 278.4 Q(\255sOutputFile=%stdout%)144 290.4 Q .204
(In this case you must also use the)108 307.2 R F1<ad71>2.704 E F0 .204
(switch, to pre)2.704 F -.15(ve)-.25 G .205
(nt Ghostscript from writing messages to standard out-).15 F(put.)108
319.2 Q 1.6 -.8(To s)108 336 T
(elect a speci\214c paper size, use the command line switch).8 E(-sP)144
352.8 Q(APERSIZE=<paper_size>)-.92 E(for instance)108 369.6 Q(-sP)144
386.4 Q(APERSIZE=a4)-.92 E(or)108 398.4 Q(-sP)144 410.4 Q(APERSIZE=le)
-.92 E -.05(ga)-.15 G(l).05 E .362(Most ISO and US paper sizes are reco\
gnized. See the usage documentation for a full list, or the de\214nitio\
ns)108 427.2 R(in the initialization \214le "gs_statd.ps".)108 439.2 Q
.017(Ghostscript can do man)108 456 R 2.517(yt)-.15 G .018
(hings other than print or vie)-2.517 F 2.518(wP)-.25 G .018
(ostScript and PDF \214les.)-2.518 F -.15(Fo)5.018 G 2.518(re).15 G .018
(xample, if you w)-2.668 F(ant)-.1 E 1.018(to kno)108 468 R 3.517(wt)
-.25 G 1.017
(he bounding box of a PostScript \(or EPS\) \214le, Ghostscript pro)
-3.517 F 1.017(vides a special "de)-.15 F 1.017(vice" that just)-.25 F
(prints out this information.)108 480 Q -.15(Fo)108 496.8 S 2.5(re).15 G
(xample, using one of the e)-2.65 E(xample \214les distrib)-.15 E
(uted with Ghostscript,)-.2 E(gs \255sDEVICE=bbox golfer)144 513.6 Q
(.ps)-.55 E(prints out)108 530.4 Q(%%BoundingBox: 0 25 583 732)144 547.2
Q(%%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445)144 559.2
Q/F2 10.95/Times-Bold@0 SF(OPTIONS)72 576 Q F1<adad>108 588 Q/F3 10
/Times-Italic@0 SF(\214lename ar)2.5 E(g1 ...)-.37 E F0 -.8(Ta)144 600 S
-.1(ke).8 G 3.349(st).1 G .849(he ne)-3.349 F .849(xt ar)-.15 F .849
(gument as a \214le name as usual, b)-.18 F .85(ut tak)-.2 F .85
(es all remaining ar)-.1 F .85(guments \(e)-.18 F -.15(ve)-.25 G 3.35
(ni).15 G 3.35(ft)-3.35 G(he)-3.35 E(y)-.15 E(ha)144 612 Q 1.91 -.15
(ve t)-.2 H 1.609(he syntactic form of switches\) and de\214nes the nam\
e "ARGUMENTS" in "userdict" \(not).15 F .318
("systemdict"\) as an array of those strings,)144 624 R F1(bef)2.819 E
(or)-.25 E(e)-.18 E F0 .319(running the \214le.)2.819 F .319
(When Ghostscript \214nishes e)5.319 F -.15(xe)-.15 G(-).15 E
(cuting the \214le, it e)144 636 Q(xits back to the shell.)-.15 E F1
<ad44>108 652.8 Q F3(name).36 E F1(=).18 E F3(tok).13 E(en)-.1 E F1
<ad64>108 664.8 Q F3(name).36 E F1(=).18 E F3(tok).13 E(en)-.1 E F0 .366
(De\214ne a name in "systemdict" with the gi)144 676.8 R -.15(ve)-.25 G
2.866(nd).15 G 2.866(e\214nition. The)-2.866 F(tok)2.866 E .365
(en must be e)-.1 F .365(xactly one tok)-.15 F .365(en \(as)-.1 F
(de\214ned by the "tok)144 688.8 Q
(en" operator\) and may contain no whitespace.)-.1 E F1<ad44>108 705.6 Q
F3(name).36 E F0 188.445(9.27 4)72 768 R(April 2019)2.5 E(2)203.445 E 0
Cg EP
%%Page: 3 3
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 184.005(GS\(1\) Ghostscript GS\(1\))72 48 R/F1
10/Times-Bold@0 SF<ad64>108 84 Q/F2 10/Times-Italic@0 SF(name).36 E F0
(De\214ne a name in "systemdict" with v)144 96 Q(alue=null.)-.25 E F1
<ad53>108 112.8 Q F2(name).36 E F1(=).18 E F2(string).34 E F1<ad73>108
124.8 Q F2(name).36 E F1(=).18 E F2(string).34 E F0 .444
(De\214ne a name in "systemdict" with a gi)144 136.8 R -.15(ve)-.25 G
2.944(ns).15 G .444(tring as v)-2.944 F 2.944(alue. This)-.25 F .444
(is dif)2.944 F .444(ferent from)-.25 F F1<ad64>2.944 E F0 5.445(.F)C
.445(or e)-5.595 F(xam-)-.15 E(ple,)144 148.8 Q F1(\255dname=35)2.5 E F0
(is equi)2.5 E -.25(va)-.25 G(lent to the program fragment).25 E
(/name 35 def)180 160.8 Q(whereas)144 172.8 Q F1(\255sname=35)2.5 E F0
(is equi)2.5 E -.25(va)-.25 G(lent to).25 E(/name \(35\) def)180 184.8 Q
F1<ad50>108 201.6 Q F0(Mak)144 201.6 Q .157(es Ghostscript to look \214\
rst in the current directory for library \214les.)-.1 F .156(By def)
5.156 F .156(ault, Ghostscript no)-.1 F .523
(longer looks in the current directory)144 213.6 R 3.023(,u)-.65 G .523
(nless, of course, the \214rst e)-3.023 F .524
(xplicitly supplied directory is ".")-.15 F(in)144 225.6 Q F1(-I)3.314 E
F0 5.813(.S)C .813(ee also the)-5.813 F F1(INITIALIZA)3.313 E .813
(TION FILES)-.95 F F0 .813(section belo)3.313 F 2.113 -.65(w, a)-.25 H
.813(nd b).65 F(undled)-.2 E F1(Use.htm)3.313 E F0 .813(for detailed)
3.313 F(discussion on search paths and ho)144 237.6 Q 2.5(wG)-.25 G
(hostcript \214nds \214les.)-2.5 E F1<ad71>108 254.4 Q F0
(Quiet startup: suppress normal startup messages, and also do the equi)
144 254.4 Q -.25(va)-.25 G(lent of).25 E F1(\255dQ)2.5 E(UIET)-.1 E F0
(.)A F1<ad67>108 271.2 Q F2(number1).36 E F1(x)A F2(number2).36 E F0
(Equi)144 283.2 Q -.25(va)-.25 G 1.915(lent to).25 F F1
(\255dDEVICEWIDTH=)4.415 E F2(number1)A F0(and)4.416 E F1
(\255dDEVICEHEIGHT=)4.416 E F2(number2)A F0 6.916(.T)C 1.916(his is for)
-6.916 F .353(the bene\214t of de)144 295.2 R .353
(vices \(such as X11 windo)-.25 F .352(ws\) that require \(or allo)-.25
F .352(w\) width and height to be speci-)-.25 F(\214ed.)144 307.2 Q F1
<ad72>108 324 Q F2(number).36 E F1<ad72>108 336 Q F2(number1).36 E F1(x)
A F2(number2).36 E F0(Equi)144 348 Q -.25(va)-.25 G 1.337(lent to).25 F
F1(\255dDEVICEXRESOLUTION=)3.837 E F2(number1)A F0(and)3.838 E F1
(\255dDEVICEYRESOLUTION=)3.838 E F2(num-)A(ber2)144 360 Q F0 5.338(.T)C
.337(his is for the bene\214t of de)-5.338 F .337
(vices such as printers that support multiple X and Y resolutions.)-.25
F(If only one number is gi)144 372 Q -.15(ve)-.25 G
(n, it is used for both X and Y resolutions.).15 E F1<ad49>108 388.8 Q
F2(dir).35 E(ectories)-.37 E F0(Adds the designated list of directories\
 at the head of the search path for library \214les.)144 400.8 Q F1<ad>
108 417.6 Q F0 .268(This is not really a switch, b)144 417.6 R .268(ut \
indicates to Ghostscript that standard input is coming from a \214le or)
-.2 F 2.763(ap)144 429.6 S .263(ipe and not interacti)-2.763 F -.15(ve)
-.25 G .263(ly from the command line.).15 F .262
(Ghostscript reads from standard input until it)5.263 F .988
(reaches end-of-\214le, e)144 441.6 R -.15(xe)-.15 G .988(cuting it lik)
.15 F 3.488(ea)-.1 G 1.288 -.15(ny o)-3.488 H .989
(ther \214le, and then continues with processing the com-).15 F .345
(mand line.)144 453.6 R .345
(When the command line has been entirely processed, Ghostscript e)5.345
F .345(xits rather than go-)-.15 F(ing into its interacti)144 465.6 Q .3
-.15(ve m)-.25 H(ode.).15 E 1.074
(Note that the normal initialization \214le "gs_init.ps" mak)108 482.4 R
1.074(es "systemdict" read-only)-.1 F 3.574(,s)-.65 G 3.575(ot)-3.574 G
1.075(he v)-3.575 F 1.075(alues of names)-.25 F .601(de\214ned with)108
494.4 R F1<ad44>3.101 E F0(,)A F1<ad64>3.101 E F0(,)A F1<ad53>3.101 E F0
3.101(,o)C(r)-3.101 E F1<ad73>3.101 E F0 .601
(cannot be changed \(although, of course, the)3.101 F 3.1(yc)-.15 G .6
(an be superseded by de\214ni-)-3.1 F
(tions in "userdict" or other dictionaries.\))108 506.4 Q/F3 10.95
/Times-Bold@0 SF(SPECIAL N)72 523.2 Q(AMES)-.219 E F1(\255dNOCA)108
535.2 Q(CHE)-.55 E F0(Disables character caching.)144 547.2 Q
(Useful only for deb)5 E(ugging.)-.2 E F1(\255dNOBIND)108 564 Q F0
(Disables the "bind" operator)144 576 Q 5(.U)-.55 G(seful only for deb)
-5 E(ugging.)-.2 E F1(\255dNODISPLA)108 592.8 Q(Y)-1 E F0
(Suppresses the normal initialization of the output de)144 604.8 Q 2.5
(vice. This)-.25 F(may be useful when deb)2.5 E(ugging.)-.2 E F1
(\255dNOP)108 621.6 Q -.5(AU)-.74 G(SE).5 E F0 1.144
(Disables the prompt and pause at the end of each page.)144 633.6 R
1.144(This may be desirable for applications)6.144 F
(where another program is dri)144 645.6 Q(ving Ghostscript.)-.25 E F1
(\255dNOPLA)108 662.4 Q(TFONTS)-.95 E F0 .187(Disables the use of fonts\
 supplied by the underlying platform \(for instance X W)144 674.4 R
(indo)-.4 E .187(ws\). This may)-.25 F
(be needed if the platform fonts look undesirably dif)144 686.4 Q
(ferent from the scalable fonts.)-.25 E F1(\255dSAFER)108 703.2 Q F0
1.913(Restricts \214le operations the job can perform.)144 715.2 R 1.914
(Strongly recommended for spoolers, con)6.914 F -.15(ve)-.4 G(rsion).15
E 1.728(scripts or other sensiti)144 727.2 R 2.028 -.15(ve e)-.25 H -.4
(nv).15 G 1.727
(ironments where a badly written or malicious PostScript program).4 F
188.445(9.27 4)72 768 R(April 2019)2.5 E(3)203.445 E 0 Cg EP
%%Page: 4 4
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 184.005(GS\(1\) Ghostscript GS\(1\))72 48 R
(code must be pre)144 84 Q -.15(ve)-.25 G
(nted from changing important \214les.).15 E/F1 10/Times-Bold@0 SF
(\255dWRITESYSTEMDICT)108 100.8 Q F0(Lea)144 112.8 Q -.15(ve)-.2 G 4.336
(s").15 G 1.836(systemdict" writable.)-4.336 F 1.837
(This is necessary when running special utility programs, b)6.836 F
1.837(ut is)-.2 F(strongly discouraged as it bypasses normal Postscript\
 security measures.)144 124.8 Q F1(\255sDEVICE=)108 141.6 Q/F2 10
/Times-Italic@0 SF(de).35 E(vice)-.15 E F0
(Selects an alternate initial output de)144 153.6 Q
(vice, as described abo)-.25 E -.15(ve)-.15 G(.).15 E F1
(\255sOutputFile=)108 170.4 Q F2(\214lename)1.91 E F0(Selects an altern\
ate output \214le \(or pipe\) for the initial output de)144 182.4 Q
(vice, as described abo)-.25 E -.15(ve)-.15 G(.).15 E/F3 10.95
/Times-Bold@0 SF(SAFER MODE)72 199.2 Q F0(The)108 211.2 Q F1(\255dSAFER)
4.261 E F0 1.761(option disables the "delete\214le" and "rename\214le" \
operators and prohibits opening piped)4.261 F .067(commands \("%pipe%)
108 223.2 R F2(cmd)A F0 .067("\). Only "%stdout" and "%stderr" can be o\
pened for writing. It also disables read-)B 1.023(ing from \214les, e)
108 235.2 R 1.023(xcept for "%stdin", \214les gi)-.15 F -.15(ve)-.25 G
3.523(na).15 G 3.523(sac)-3.523 G 1.023(ommand line ar)-3.523 F 1.023
(gument, and \214les contained in paths)-.18 F(gi)108 247.2 Q -.15(ve)
-.25 G 2.906(nb).15 G 2.906(yL)-2.906 G(IBP)-2.906 E -1.11(AT)-.92 G
2.906(Ha)1.11 G .406(nd FONTP)-2.906 F -1.11(AT)-.92 G 2.906(Ho)1.11 G
2.906(rs)-2.906 G .406(peci\214ed by the system params /F)-2.906 F .407
(ontResourceDir and /GenericRe-)-.15 F(sourceDir)108 259.2 Q(.)-.55 E
1.168(This mode also sets the .LockSafetyP)108 276 R 1.167
(arams parameter of the initial output de)-.15 F 1.167
(vice to protect ag)-.25 F 1.167(ainst pro-)-.05 F 1.54
(grams that attempt to write to \214les using the OutputFile de)108 288
R 1.541(vice parameter)-.25 F 4.041(.S)-.55 G 1.541(ince the de)-4.041 F
1.541(vice parameters)-.25 F 1.715(speci\214ed on the command line, inc\
luding OutputFile, are set prior to SAFER mode, use of "-sOutput-)108
300 R(File=..." on the command line is unrestricted.)108 312 Q 2.288
(SAFER mode pre)108 328.8 R -.15(ve)-.25 G 2.289
(nts changing the /GenericResourceDir).15 F 4.789(,/)-.4 G -.15(Fo)
-4.789 G(ntResourceDir).15 E 4.789(,/)-.4 G(SystemP)-4.789 E(aramsP)-.15
E(assw)-.15 E(ord,)-.1 E(and /StartJobP)108 340.8 Q(assw)-.15 E(ord.)-.1
E .134(While SAFER mode is not the def)108 357.6 R .134
(ault, it is the def)-.1 F .134(ault for man)-.1 F 2.634(yw)-.15 G .134
(rapper scripts such as ps2pdf and may be)-2.634 F .535(the def)108
369.6 R .536(ault in a subsequent release of Ghostscript.)-.1 F .536
(Thus when running programs that need to open \214les or)5.536 F .849
(set restricted parameters you should pass the)108 381.6 R F1
(\255dNOSAFER)3.349 E F0 .848(command line option or its synon)3.349 F
(ym)-.15 E F1(\255dDE-)3.348 E(LA)108 393.6 Q(YSAFER)-1 E F0(.)A .071
(When running with)108 410.4 R F1(\255dNOSAFER)2.571 E F0 .071
(it is possible to perform a "sa)2.571 F -.15(ve)-.2 G 2.571("f).15 G
(ollo)-2.571 E .071(wed by ".setsafe", e)-.25 F -.15(xe)-.15 G .072
(cute a \214le or).15 F .841(procedure in SAFER mode, and then use "res\
tore" to return to NOSAFER mode.)108 422.4 R .841(In order to pre)5.841
F -.15(ve)-.25 G .841(nt the).15 F(sa)108 434.4 Q .671 -.15(ve o)-.2 H
.372(bject from being restored by the foreign \214le or procedure, the \
".runandhide" operator should be used).15 F(to hide the sa)108 446.4 Q
.3 -.15(ve o)-.2 H(bject from the restricted procedure.).15 E F3(FILES)
72 463.2 Q F0 .229(The locations of man)108 475.2 R 2.729(yG)-.15 G .228
(hostscript run-time \214les are compiled into the e)-2.729 F -.15(xe)
-.15 G .228(cutable when it is b).15 F 2.728(uilt. Run)-.2 F(")2.728 E
F1(gs)A(-h)108 487.2 Q F0 2.624("t)C 2.624<6f8c>-2.624 G .125(nd the lo\
cation of Ghostscript documentation on your system, from which you can \
get more details.)-2.624 F(On a Debian system the)108 499.2 Q 2.5(ya)
-.15 G(re in)-2.5 E F1(/usr)2.5 E F0(.)A F1(/usr/shar)108 516 Q
(e/ghostscript/[0-9]*.[0.9]*/*)-.18 E F0(Startup \214les, utilities, an\
d basic font de\214nitions \(where [0-9]*.[0.9]* is the ghostscript v)
144 528 Q(ersion\))-.15 E F1(/usr/shar)108 544.8 Q(e/f)-.18 E
(onts/type1/gsf)-.25 E(onts/*)-.25 E F0
(More font de\214nitions from the gsfonts package)144 556.8 Q F1
(/usr/shar)108 573.6 Q(e/doc/ghostscript/examples/*)-.18 E F0(Ghostscri\
pt demonstration \214les \(if ghostscript-doc package is installed\))144
585.6 Q F1(/usr/shar)108 602.4 Q(e/doc/ghostscript/*)-.18 E F0(Di)144
614.4 Q -.15(ve)-.25 G
(rse document \214les \(may need to install ghostscript-doc package\))
.15 E F3(INITIALIZA)72 631.2 Q(TION FILES)-1.04 E F0 .001(When looking \
for the initialization \214les "gs_*.ps", the \214les related to fonts,\
 or the \214le for the "run" operator)108 643.2 R(,)-.4 E .543
(Ghostscript \214rst tries to open the \214le with the name as gi)108
655.2 R -.15(ve)-.25 G .543(n, using the current w).15 F .544
(orking directory if no di-)-.1 F 1.196(rectory is speci\214ed.)108
667.2 R 1.196(If this f)6.196 F 1.196(ails, and the \214le name doesn')
-.1 F 3.695(ts)-.18 G 1.195(pecify an e)-3.695 F 1.195
(xplicit directory or dri)-.15 F 1.495 -.15(ve \()-.25 H 1.195(for in-)
.15 F(stance, doesn')108 679.2 Q 2.5(tc)-.18 G(ontain "/" on Unix syste\
ms\), Ghostscript tries directories in this order:)-2.5 E(1.)108 696 Q
(the directories speci\214ed by the)128 696 Q F1<ad49>2.5 E F0
(switches in the command line \(see belo)2.5 E(w\), if an)-.25 E(y;)-.15
E(2.)108 712.8 Q(the directories speci\214ed by the)128 712.8 Q F1
(GS_LIB)2.5 E F0(en)2.5 E(vironment v)-.4 E(ariable, if an)-.25 E(y;)
-.15 E 188.445(9.27 4)72 768 R(April 2019)2.5 E(4)203.445 E 0 Cg EP
%%Page: 5 5
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 184.005(GS\(1\) Ghostscript GS\(1\))72 48 R(3.)
108 84 Q .387(the directories speci\214ed by the)128 84 R/F1 10
/Times-Bold@0 SF(GS_LIB_DEF)2.888 E -.5(AU)-.9 G -.92(LT).5 G F0 .388
(macro in the Ghostscript mak)3.808 F .388(e\214le when the e)-.1 F -.15
(xe)-.15 G(-).15 E .844(cutable w)128 96 R .844(as b)-.1 F(uilt.)-.2 E
F1(GS_LIB_DEF)5.844 E -.5(AU)-.9 G -.92(LT).5 G F0 .843
(is "/usr/share/ghostscript/[0-9]*.[0-9]*/lib" on a Debian sys-)4.263 F
(tem where "[0-9]*.[0-9]*" represents the Ghostscript v)128 108 Q
(ersion number)-.15 E .437(Each of these \()108 124.8 R F1(GS_LIB_DEF)A
-.5(AU)-.9 G -.92(LT).5 G F0(,).92 E F1(GS_LIB)2.937 E F0 2.937(,a)C(nd)
-2.937 E F1<ad49>2.937 E F0 .438
(parameter\) may be either a single directory or a list)2.937 F
(of directories separated by ":".)108 136.8 Q/F2 10.95/Times-Bold@0 SF
(ENVIR)72 153.6 Q(ONMENT)-.329 E F1(GS_OPTIONS)108 165.6 Q F0
(String of options to be processed before the command line options)144
177.6 Q F1(GS_DEVICE)108 194.4 Q F0(Used to specify an output de)144
206.4 Q(vice)-.25 E F1(GS_FONTP)108 223.2 Q -.95(AT)-.74 G(H).95 E F0
-.15(Pa)144 235.2 S(th names used to search for fonts).15 E F1(GS_LIB)
108 252 Q F0 -.15(Pa)144 264 S
(th names for initialization \214les and fonts).15 E F1(TEMP)108 280.8 Q
F0(Where temporary \214les are made)144 280.8 Q F2 2.738(XR)72 297.6 S
(ESOURCES)-2.738 E F0 .376
(Ghostscript, or more properly the X11 display de)108 309.6 R .375
(vice, looks for the follo)-.25 F .375(wing resources under the program)
-.25 F(name "Ghostscript":)108 321.6 Q F1(borderW)108 338.4 Q(idth)-.18
E F0(The border width in pix)144 350.4 Q(els \(def)-.15 E(ault = 1\).)
-.1 E F1(borderColor)108 367.2 Q F0(The name of the border color \(def)
144 379.2 Q(ault = black\).)-.1 E F1(geometry)108 396 Q F0(The windo)144
408 Q 2.5(ws)-.25 G(ize and placement, WxH+X+Y \(def)-2.5 E
(ault is NULL\).)-.1 E F1(xResolution)108 424.8 Q F0 .932
(The number of x pix)144 436.8 R .932(els per inch \(def)-.15 F .932
(ault is computed from)-.1 F F1 -.18(Wi)3.433 G(dthOfScr).18 E(een)-.18
E F0(and)3.433 E F1 -.18(Wi)3.433 G(dthMMOf-).18 E(Scr)144 448.8 Q(een)
-.18 E F0(\).)A F1(yResolution)108 465.6 Q F0 .65(The number of y pix)
144 477.6 R .649(els per inch \(def)-.15 F .649(ault is computed from)
-.1 F F1(HeightOfScr)3.149 E(een)-.18 E F0(and)3.149 E F1(HeightMMOf-)
3.149 E(Scr)144 489.6 Q(een)-.18 E F0(\).)A F1(useBackingPixmap)108
506.4 Q F0(Determines whether backing store is to be used for sa)144
518.4 Q(ving display windo)-.2 E 2.5(w\()-.25 G(def)-2.5 E
(ault = true\).)-.1 E .327
(See the usage document for a more complete list of resources.)108 535.2
R 1.927 -.8(To s)5.327 H .327(et these resources on Unix, put them in).8
F 2.5<618c>108 547.2 S(le such as "~/.Xresources" in the follo)-2.5 E
(wing form:)-.25 E 16.34(Ghostscript*geometry: 612x792\2550+0)144 564 R
(Ghostscript*xResolution: 72)144 576 Q(Ghostscript*yResolution: 72)144
588 Q(Then mer)108 604.8 Q(ge these resources into the X serv)-.18 E
(er')-.15 E 2.5(sr)-.55 G(esource database:)-2.5 E 2.5(%x)144 621.6 S
(rdb \255mer)-2.5 E(ge ~/.Xresources)-.18 E F2(SEE ALSO)72 638.4 Q F0
.901(The v)108 650.4 R .901(arious Ghostscript document \214les \(abo)
-.25 F -.15(ve)-.15 G .901(\), especially).15 F F1(Use.htm)3.401 E F0
5.901(.O)C 3.401(nD)-5.901 G .9(ebian you may need to install)-3.401 F
(ghostscript-doc before reading the documentation.)108 662.4 Q F2 -.11
(BU)72 679.2 S(GS).11 E F0(See http://b)108 691.2 Q
(ugs.ghostscript.com/ and the Usenet ne)-.2 E
(ws group comp.lang.postscript.)-.25 E 188.445(9.27 4)72 768 R
(April 2019)2.5 E(5)203.445 E 0 Cg EP
%%Page: 6 6
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 184.005(GS\(1\) Ghostscript GS\(1\))72 48 R/F1
10.95/Times-Bold@0 SF(VERSION)72 84 Q F0(This document w)108 96 Q
(as last re)-.1 E(vised for Ghostscript v)-.25 E(ersion 9.27.)-.15 E F1
-.548(AU)72 112.8 S(THOR).548 E F0(Artife)108 124.8 Q 4.865(xS)-.15 G
(oftw)-4.865 E 2.366
(are, Inc. are the primary maintainers of Ghostscript.)-.1 F 2.366
(Russell J. Lang, gsvie)7.366 F 4.866(wa)-.25 G 4.866(tg)-4.866 G(host-)
-4.866 E(gum.com.au, is the author of most of the MS W)108 136.8 Q(indo)
-.4 E(ws code in Ghostscript.)-.25 E 188.445(9.27 4)72 768 R(April 2019)
2.5 E(6)203.445 E 0 Cg EP
%%Trailer
end
%%EOF

Not very pretty, luckily we have ghostscript which is the basis of many smaller commands, such as one to convert postscript to pdf. The command is called ps2pdf. When can connect the two commands together in so called pipeline with the | character -- which is called the pipe because of this usage.

First let's make a folder for our manuals

In [6]:
!mkdir -p man

Now let's run man gs and pipe the output to ps2pdf, saving in the file man/gs.pdf.

In [7]:
!man -t gs | ps2pdf - man/gs.pdf

A PDF Toolkit

Make some man-uals with ps2pdf

In [9]:
!man -t psnup | ps2pdf - man/psnup.pdf
!man -t pstops | ps2pdf - man/pstops.pdf
!man -t ps2pdf | ps2pdf - man/ps2pdf.pdf
!man -t pdf2ps | ps2pdf - man/pdf2ps.pdf
!man -t pdftk | ps2pdf - man/pdftk.pdf
!man -t pdfposter | ps2pdf - man/pdfposter.pdf
!man -t poster | ps2pdf - man/poster.pdf
In [ ]:
# NB These tools are often part of other packages of tools, for instanced:
# apt install ghostscript psutils pdfposter

Read the label with pdfinfo

PDFs have useful info like number of pages and the (default) page size, but also can contain various metadata like Title, Keywords, and Author, and the "Producer" which often indicates what software was used to make the file.

In [10]:
!pdfinfo txt/language.pdf
Title:          
Keywords:       
Author:         
Producer:       cairo 1.16.0 (https://cairographics.org)
CreationDate:   Wed Oct 28 19:43:01 2020 CET
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          4
Encrypted:      no
Page size:      595 x 841 pts
Page rot:       0
File size:      57323 bytes
Optimized:      no
PDF version:    1.5

Back to the Future with pdf2ps

Many of the commands discussed here have their origins in the 1990s and were written to work with Postscript. Luckily there's also a pdf2ps command to go from PDF to Postscript. This command outputs (unless otherwise told) in a file with the same name but extension .ps

In [11]:
!pdf2ps txt/language.pdf

psnup saves trees

In [12]:
!psnup -2 language.ps psnup.ps
[1] [2] Wrote 2 pages, 481771 bytes

To look at it, run the ps2pdf...

In [22]:
!ps2pdf psnup.ps psnup.pdf
DEBUG: FC_WEIGHT didn't match

AND LOOK HERE: psnup.pdf

In [17]:
!psnup -2 -p a3 -s a3 language.ps psnup.ps
[1] [2] Wrote 2 pages, 481777 bytes

Repeat the steps above to see it (make sure you close the PDF to reload it).

The -c option lays out in column order (instead of rows). Check out the manual.

In [21]:
!psnup -16 -c language.ps psnup.ps
[1] Wrote 1 pages, 485929 bytes
In [19]:
!psnup -16 -c -p a0 language.ps psnup.ps
[1] Wrote 1 pages, 485997 bytes

pdftk is another PDF toolkit

This command can do many things. Let's use it to extract a page

In [ ]:
!pdftk A=txt/language.pdf cat A1 output 1.pdf

Scale (among other things) with the multi-faceted pstops

In [24]:
!pdf2ps txt/language.pdf 1.ps
# Scale up A4 to A2, A0
!pstops "0@2.0" -pa2 1.ps 1.output.ps
!pstops "0@4.0" -pa0 1.ps 1.a0.ps
[1] [2] [3] [4] Wrote 4 pages, 481656 bytes
[1] [2] [3] [4] Wrote 4 pages, 481656 bytes

NB: When subsequently using ps2pdf on a resized postscript file, you should explictly specify the output paper size:

In [26]:
!ps2pdf -sPAPERSIZE=a0 1.a0.ps 1.a0.pdf
DEBUG: FC_WEIGHT didn't match
In [27]:
!pdfinfo 1.a0.pdf
Creator:        GPL Ghostscript 927 (ps2write)
Producer:       GPL Ghostscript 9.27
CreationDate:   Wed Oct 28 21:23:58 2020 CET
ModDate:        Wed Oct 28 21:23:58 2020 CET
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          4
Encrypted:      no
Page size:      2384 x 3370 pts (A0)
Page rot:       0
File size:      63970 bytes
Optimized:      no
PDF version:    1.4

From pdf to ps and back again with a pipeline sandwich

You might say, what a drag that pstops only scales postscript files and not PDF, well just wrap it in a Pipeline sandwich...

In [ ]:
!pdf2ps 1.pdf - | pstops "0@4.0" -pa2 | ps2pdf -sPAPERSIZE=a0 - 1.a0.pdf

Make a blank PDF with python and reportlab.pdfgen.canvas

In [ ]:
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.pagesizes import A4
c = Canvas("blanka4.pdf", pagesize=A4, bottomup=0)
c.showPage()
c.save()

Tile and zoom with poster

From the poster manual:

Poster can be used to create a large poster by building it from multiple pages and/or printing it on large me-dia. Itexpects as input a generic (encapsulated) postscript file, normally printing on a single page.Theoutput is again a postscript file, maybe containing multiple pages together building the poster.The outputpages bear cutmarks and have slightly overlapping images for easier assembling. The input picture will bescaled to obtain the desired size

In [28]:
#!poster -mA3 -pA0 1.ps | ps2pdf - > poster.poster.pdf
!poster -v -c0 -iA4 -mA4 -pA0 1.ps | ps2pdf - > poster.poster.pdf
Using default whitemargin of 0
Deciding for 4 columns and 4 rows of portrait pages.
Deciding for a scale factor of 4
print page 1
DEBUG: FC_WEIGHT didn't match
print page 2
print page 3
print page 4
print page 5
print page 6
print page 7
print page 8
print page 9
print page 10
print page 11
print page 12
print page 13
print page 14
print page 15
print page 16
print page 17
print page 18
print page 19
print page 20
print page 21
print page 22
print page 23
print page 24
print page 25
print page 26
print page 27
print page 28
print page 29
print page 30
print page 31
print page 32
print page 33
print page 34
print page 35
print page 36
print page 37
print page 38
print page 39
print page 40
print page 41
print page 42
print page 43
print page 44
print page 45
print page 46
print page 47
print page 48
print page 49
print page 50
print page 51
print page 52
print page 53
print page 54
print page 55
print page 56
print page 57
print page 58
print page 59
print page 60
print page 61
print page 62
print page 63
print page 64

The newer pdfposter works directly with PDF files, and has slightly different options.

For example to prints an A4 input file on 8 A3 pages, forming an A0 poster:

In [30]:
!pdfposter -mA3 -pA0 1.a0.pdf pdfposter.pdf

Puzzle: Combine tools to make a poster with different elements

In [ ]: