{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# The Ghostscript Imposition\n",
    "\n",
    "> Imposition is one of the fundamental steps in the prepress printing process. It consists of the arrangement of the printed product’s pages on the printer’s sheet, in order to obtain faster printing, simplify binding and reduce paper waste.\n",
    "\n",
    "> 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. \n",
    "\n",
    "https://en.wikipedia.org/wiki/Imposition\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Paged media: A timeline\n",
    "\n",
    "**1980s**\n",
    "\n",
    "[![](https://www.graphic-reseau.com/media/catalog/product/cache/3/small_image/170x170/9df78eab33525d08d6e5fb8d27136e95/l/o/logo-adobepostscript.png)](https://en.wikipedia.org/wiki/PostScript) [![](https://www.ghostscript.com/images/ghostscript_logo.png)](https://en.wikipedia.org/wiki/Ghostscript)\n",
    "\n",
    "\n",
    "**1990s**\n",
    "\n",
    "[![](https://web.archive.org/web/19970304211647im_/http://www3.adobe.com/GIFS/getacro.gif)](https://en.wikipedia.org/wiki/PDF) [![](https://pzwiki.wdka.nl/mw-mediadesign/images/f/f4/Mosaic.png)](https://en.wikipedia.org/wiki/HTML)\n",
    "\n",
    "[Dave Raggett's Touch of Style tutorial](https://www.w3.org/MarkUp/Guide/Style) 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...\n",
    "\n",
    "**TODAY**\n",
    "\n",
    "![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/HTML5_logo_and_wordmark.svg/180px-HTML5_logo_and_wordmark.svg.png) [![](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/CSS3_logo_and_wordmark.svg/180px-CSS3_logo_and_wordmark.svg.png)](https://drafts.csswg.org/css-page-3/) ![](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7d/Adobe_PDF.svg/150px-Adobe_PDF.svg.png)\n",
    "\n",
    "https://en.wikipedia.org/wiki/CSS\n",
    "\n",
    "CSS3 includes an extensive [Paged Media Specification](https://drafts.csswg.org/css-page-3/) 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."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The \"UNIX\" philosophy of small tools composed together (and the pipeline)\n",
    "![](https://thedailykylie.files.wordpress.com/2013/03/tool-box.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use the !shell\n",
    "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..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wed 28 Oct 2020 09:10:50 PM CET\n"
     ]
    }
   ],
   "source": [
    "!date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mb\n"
     ]
    }
   ],
   "source": [
    "!whoami"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "aalib-pdf.ipynb\t\t\t   nltk-tfidf.ipynb\n",
      "ASCII-canvas-to-PDF.ipynb\t   patches\n",
      "ASCII-canvas-to-PDF.pdf\t\t   patterns-generating.ipynb\n",
      "ASCII-patch-making.ipynb\t   patterns-searching-for.ipynb\n",
      "ASCII-quilt.ipynb\t\t   PIL-basics.ipynb\n",
      "ASCII-quilt-making.ipynb\t   pillow_imagedraw.ipynb\n",
      "ASCII-QUILT.pdf\t\t\t   py\n",
      "Concordance_Patches\t\t   python-cheatsheet.ipynb\n",
      "concordance_quilt.ipynb\t\t   quilt.ipynb\n",
      "dictionary-step-by-step.ipynb\t   quilts\n",
      "fonts\t\t\t\t   reportlab-canvas-A4-bag-of-words.ipynb\n",
      "hotseat.ipynb\t\t\t   reportlab-canvas-A4-bag-of-words.pdf\n",
      "img\t\t\t\t   reportlab-cheatsheet.ipynb\n",
      "json-dataset.json\t\t   reportlab_tests.ipynb\n",
      "json-making-datasets.ipynb\t   TheGhostscriptImposition.ipynb\n",
      "mydocument.pdf\t\t\t   txt\n",
      "nltk-frequency-distribution.ipynb  untitled.txt\n",
      "NLTKing.ipynb\t\t\t   weasyprint.ipynb\n",
      "nltk-pos-tagger.ipynb\t\t   weasyprint-test.pdf\n",
      "nltk-similar-words.ipynb\t   WordNet-synsets.ipynb\n"
     ]
    }
   ],
   "source": [
    "!ls"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## An zine introduction to the terminal\n",
    "\n",
    "https://solarpunk.cool/zines/map-is-the-territory/\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## MAN oh MAN"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GS(1)                             Ghostscript                            GS(1)\n",
      "\n",
      "NAME\n",
      "       gs  -  Ghostscript  (PostScript  and  PDF language interpreter and pre‐\n",
      "       viewer)\n",
      "\n",
      "SYNOPSIS\n",
      "       gs [ options ] [ files ] ...\n",
      "\n",
      "DESCRIPTION\n",
      "       The gs command invokes Ghostscript, an interpreter  of  Adobe  Systems'\n",
      "       PostScript(tm)  and Portable Document Format (PDF) languages.  gs reads\n",
      "       \"files\" in sequence and executes them as  Ghostscript  programs.  After\n",
      "       doing this, it reads further input from the standard input stream (nor‐\n",
      "       mally the keyboard), interpreting each line separately and output to an\n",
      "       output  device (may be a file or an X11 window preview, see below). The\n",
      "       interpreter exits gracefully when it encounters the \"quit\" command (ei‐\n",
      "       ther  in  a file or from the keyboard), at end-of-file, or at an inter‐\n",
      "       rupt signal (such as Control-C at the keyboard).\n",
      "\n",
      "       The interpreter recognizes many option switches, some of which are  de‐\n",
      "       scribed below. Please see the usage documentation for complete informa‐\n",
      "       tion. Switches may appear anywhere in the command line and apply to all\n",
      "       files  thereafter.   Invoking Ghostscript with the -h or -? switch pro‐\n",
      "       duces a message which shows several useful switches,  all  the  devices\n",
      "       known  to  that  executable,  and the search path for fonts; on Unix it\n",
      "       also shows the location of detailed documentation.\n",
      "\n",
      "       Ghostscript may be built to use many different output devices.  To  see\n",
      "       which devices your executable includes, run \"gs -h\".\n",
      "\n",
      "       Unless  you specify a particular device, Ghostscript normally opens the\n",
      "       first one of those and directs output to it.\n",
      "\n",
      "       If you have installed the ghostscript-x Debian package and are under X,\n",
      "       the  default device is an X11 window (previewer), else ghostscript will\n",
      "       use the bbox device and print on stdout the dimension of the postscript\n",
      "       file.\n",
      "\n",
      "       So  if the first one in the list is the one you want to use, just issue\n",
      "       the command\n",
      "\n",
      "            gs myfile.ps\n",
      "\n",
      "       You can also check the set of  available  devices  from  within  Ghost‐\n",
      "       script: invoke Ghostscript and type\n",
      "\n",
      "            devicenames ==\n",
      "\n",
      "       but  the  first device on the resulting list may not be the default de‐\n",
      "       vice you determine with \"gs -h\".  To specify \"AbcXyz\"  as  the  initial\n",
      "       output device, include the switch\n",
      "\n",
      "            -sDEVICE=AbcXyz\n",
      "\n",
      "       For example, for output to an Epson printer you might use the command\n",
      "\n",
      "            gs -sDEVICE=epson myfile.ps\n",
      "\n",
      "       The  \"-sDEVICE=\"  switch  must  precede  the first mention of a file to\n",
      "       print, and only the switch's first use has any effect.\n",
      "\n",
      "       Finally, you can specify a default device in the  environment  variable\n",
      "       GS_DEVICE.  The order of precedence for these alternatives from highest\n",
      "       to lowest (Ghostscript uses the device defined highest in the list) is:\n",
      "\n",
      "       Some devices can support different resolutions (densities).  To specify\n",
      "       the resolution on such a printer, use the \"-r\" switch:\n",
      "\n",
      "            gs -sDEVICE=<device> -r<xres>x<yres>\n",
      "\n",
      "       For  example,  on a 9-pin Epson-compatible printer, you get the lowest-\n",
      "       density (fastest) mode with\n",
      "\n",
      "            gs -sDEVICE=epson -r60x72\n",
      "\n",
      "       and the highest-density (best output quality) mode with\n",
      "\n",
      "            gs -sDEVICE=epson -r240x72.\n",
      "\n",
      "       If you select a printer as the output device, Ghostscript  also  allows\n",
      "       you  to  choose  where Ghostscript sends the output -- on Unix systems,\n",
      "       usually to a temporary file.  To send the output to a  file  \"foo.xyz\",\n",
      "       use the switch\n",
      "\n",
      "            -sOutputFile=foo.xyz\n",
      "\n",
      "       You  might  want  to  print each page separately.  To do this, send the\n",
      "       output to a series of files \"foo1.xyz, foo2.xyz, ...\" using the \"-sOut‐\n",
      "       putFile=\" switch with \"%d\" in a filename template:\n",
      "\n",
      "            -sOutputFile=foo%d.xyz\n",
      "\n",
      "       Each resulting file receives one page of output, and the files are num‐\n",
      "       bered in sequence.  \"%d\" is a printf format specification; you can also\n",
      "       use a variant like \"%02d\".\n",
      "\n",
      "       You can also send output to a pipe.  For example, to pipe output to the\n",
      "       \"lpr\" command (which, on many Unix systems, directs it to  a  printer),\n",
      "       use the option\n",
      "\n",
      "            -sOutputFile=%pipe%lpr\n",
      "\n",
      "       You can also send output to standard output:\n",
      "\n",
      "            -sOutputFile=-\n",
      "       or\n",
      "            -sOutputFile=%stdout%\n",
      "\n",
      "       In  this  case  you must also use the -q switch, to prevent Ghostscript\n",
      "       from writing messages to standard output.\n",
      "\n",
      "       To select a specific paper size, use the command line switch\n",
      "\n",
      "            -sPAPERSIZE=<paper_size>\n",
      "\n",
      "       for instance\n",
      "\n",
      "            -sPAPERSIZE=a4\n",
      "       or\n",
      "            -sPAPERSIZE=legal\n",
      "\n",
      "       Most ISO and US paper sizes are recognized. See the usage documentation\n",
      "       for  a  full  list,  or  the  definitions  in  the  initialization file\n",
      "       \"gs_statd.ps\".\n",
      "\n",
      "       Ghostscript can do many things other than print or view PostScript  and\n",
      "       PDF  files.   For  example,  if  you want to know the bounding box of a\n",
      "       PostScript (or EPS) file, Ghostscript provides a special \"device\"  that\n",
      "       just prints out this information.\n",
      "\n",
      "       For  example,  using  one  of the example files distributed with Ghost‐\n",
      "       script,\n",
      "\n",
      "            gs -sDEVICE=bbox golfer.ps\n",
      "\n",
      "       prints out\n",
      "\n",
      "            %%BoundingBox: 0 25 583 732\n",
      "            %%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445\n",
      "\n",
      "OPTIONS\n",
      "       -- filename arg1 ...\n",
      "              Takes the next argument as a file name as usual, but  takes  all\n",
      "              remaining  arguments  (even  if  they have the syntactic form of\n",
      "              switches) and defines the name \"ARGUMENTS\"  in  \"userdict\"  (not\n",
      "              \"systemdict\")  as  an array of those strings, before running the\n",
      "              file.  When Ghostscript finishes executing the  file,  it  exits\n",
      "              back to the shell.\n",
      "\n",
      "       -Dname=token\n",
      "       -dname=token\n",
      "              Define  a  name  in \"systemdict\" with the given definition.  The\n",
      "              token must be exactly one token (as defined by the \"token\" oper‐\n",
      "              ator) and may contain no whitespace.\n",
      "\n",
      "       -Dname\n",
      "       -dname Define a name in \"systemdict\" with value=null.\n",
      "\n",
      "       -Sname=string\n",
      "       -sname=string\n",
      "              Define  a  name  in  \"systemdict\"  with a given string as value.\n",
      "              This is different from -d.  For example, -dname=35 is equivalent\n",
      "              to the program fragment\n",
      "                   /name 35 def\n",
      "              whereas -sname=35 is equivalent to\n",
      "                   /name (35) def\n",
      "\n",
      "       -P     Makes Ghostscript to look first in the current directory for li‐\n",
      "              brary files.  By default, Ghostscript no  longer  looks  in  the\n",
      "              current  directory, unless, of course, the first explicitly sup‐\n",
      "              plied directory is \".\" in -I.  See also the INITIALIZATION FILES\n",
      "              section  below,  and  bundled Use.htm for detailed discussion on\n",
      "              search paths and how Ghostcript finds files.\n",
      "\n",
      "       -q     Quiet startup: suppress normal startup messages, and also do the\n",
      "              equivalent of -dQUIET.\n",
      "\n",
      "       -gnumber1xnumber2\n",
      "              Equivalent  to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2.\n",
      "              This is for the benefit of devices (such as  X11  windows)  that\n",
      "              require (or allow) width and height to be specified.\n",
      "\n",
      "       -rnumber\n",
      "       -rnumber1xnumber2\n",
      "              Equivalent  to  -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLU‐\n",
      "              TION=number2.  This is for the benefit of devices such as print‐\n",
      "              ers that support multiple X and Y resolutions.  If only one num‐\n",
      "              ber is given, it is used for both X and Y resolutions.\n",
      "\n",
      "       -Idirectories\n",
      "              Adds the designated list of  directories  at  the  head  of  the\n",
      "              search path for library files.\n",
      "\n",
      "       -      This  is  not really a switch, but indicates to Ghostscript that\n",
      "              standard input is coming from a file or a pipe and not  interac‐\n",
      "              tively  from  the command line.  Ghostscript reads from standard\n",
      "              input until it reaches end-of-file, executing it like any  other\n",
      "              file, and then continues with processing the command line.  When\n",
      "              the command line has been entirely processed, Ghostscript  exits\n",
      "              rather than going into its interactive mode.\n",
      "\n",
      "       Note  that  the  normal initialization file \"gs_init.ps\" makes \"system‐\n",
      "       dict\" read-only, so the values of names defined with -D, -d, -S, or  -s\n",
      "       cannot be changed (although, of course, they can be superseded by defi‐\n",
      "       nitions in \"userdict\" or other dictionaries.)\n",
      "\n",
      "SPECIAL NAMES\n",
      "       -dNOCACHE\n",
      "              Disables character caching.  Useful only for debugging.\n",
      "\n",
      "       -dNOBIND\n",
      "              Disables the \"bind\" operator.  Useful only for debugging.\n",
      "\n",
      "       -dNODISPLAY\n",
      "              Suppresses the normal initialization of the output device.  This\n",
      "              may be useful when debugging.\n",
      "\n",
      "       -dNOPAUSE\n",
      "              Disables the prompt and pause at the end of each page.  This may\n",
      "              be desirable for applications where another program  is  driving\n",
      "              Ghostscript.\n",
      "\n",
      "       -dNOPLATFONTS\n",
      "              Disables  the  use  of fonts supplied by the underlying platform\n",
      "              (for instance X Windows). This may be  needed  if  the  platform\n",
      "              fonts look undesirably different from the scalable fonts.\n",
      "\n",
      "       -dSAFER\n",
      "              Restricts  file operations the job can perform.  Strongly recom‐\n",
      "              mended for spoolers, conversion scripts or other sensitive envi‐\n",
      "              ronments  where  a badly written or malicious PostScript program\n",
      "              code must be prevented from changing important files.\n",
      "\n",
      "       -dWRITESYSTEMDICT\n",
      "              Leaves \"systemdict\" writable.  This is  necessary  when  running\n",
      "              special  utility programs, but is strongly discouraged as it by‐\n",
      "              passes normal Postscript security measures.\n",
      "\n",
      "       -sDEVICE=device\n",
      "              Selects an alternate initial output device, as described above.\n",
      "\n",
      "       -sOutputFile=filename\n",
      "              Selects an alternate output file (or pipe) for the initial  out‐\n",
      "              put device, as described above.\n",
      "\n",
      "SAFER MODE\n",
      "       The -dSAFER option disables the \"deletefile\" and \"renamefile\" operators\n",
      "       and prohibits opening piped commands (\"%pipe%cmd\"). Only \"%stdout\"  and\n",
      "       \"%stderr\"  can  be  opened  for  writing. It also disables reading from\n",
      "       files, except for \"%stdin\", files given as a command line argument, and\n",
      "       files  contained in paths given by LIBPATH and FONTPATH or specified by\n",
      "       the system params /FontResourceDir and /GenericResourceDir.\n",
      "\n",
      "       This mode also sets the .LockSafetyParams parameter of the initial out‐\n",
      "       put  device  to protect against programs that attempt to write to files\n",
      "       using the OutputFile device  parameter.  Since  the  device  parameters\n",
      "       specified  on  the command line, including OutputFile, are set prior to\n",
      "       SAFER mode, use of \"-sOutputFile=...\" on  the  command  line  is  unre‐\n",
      "       stricted.\n",
      "\n",
      "       SAFER mode prevents changing the /GenericResourceDir, /FontResourceDir,\n",
      "       /SystemParamsPassword, and /StartJobPassword.\n",
      "\n",
      "       While SAFER mode is not the default, it is the default for many wrapper\n",
      "       scripts  such  as ps2pdf and may be the default in a subsequent release\n",
      "       of Ghostscript.  Thus when running programs that need to open files  or\n",
      "       set  restricted  parameters  you should pass the -dNOSAFER command line\n",
      "       option or its synonym -dDELAYSAFER.\n",
      "\n",
      "       When running with -dNOSAFER it is possible to perform a \"save\" followed\n",
      "       by  \".setsafe\", execute a file or procedure in SAFER mode, and then use\n",
      "       \"restore\" to return to NOSAFER mode.  In order to prevent the save  ob‐\n",
      "       ject  from  being  restored  by  the  foreign  file  or  procedure, the\n",
      "       \".runandhide\" operator should be used to hide the save object from  the\n",
      "       restricted procedure.\n",
      "\n",
      "FILES\n",
      "       The  locations of many Ghostscript run-time files are compiled into the\n",
      "       executable when it is built.  Run \"gs  -h\"  to  find  the  location  of\n",
      "       Ghostscript  documentation  on your system, from which you can get more\n",
      "       details. On a Debian system they are in /usr.\n",
      "\n",
      "       /usr/share/ghostscript/[0-9]*.[0.9]*/*\n",
      "              Startup files, utilities,  and  basic  font  definitions  (where\n",
      "              [0-9]*.[0.9]* is the ghostscript version)\n",
      "\n",
      "       /usr/share/fonts/type1/gsfonts/*\n",
      "              More font definitions from the gsfonts package\n",
      "\n",
      "       /usr/share/doc/ghostscript/examples/*\n",
      "              Ghostscript  demonstration  files (if ghostscript-doc package is\n",
      "              installed)\n",
      "\n",
      "       /usr/share/doc/ghostscript/*\n",
      "              Diverse document files  (may  need  to  install  ghostscript-doc\n",
      "              package)\n",
      "\n",
      "INITIALIZATION FILES\n",
      "       When  looking for the initialization files \"gs_*.ps\", the files related\n",
      "       to fonts, or the file for the \"run\" operator, Ghostscript  first  tries\n",
      "       to  open the file with the name as given, using the current working di‐\n",
      "       rectory if no directory is specified.  If this fails, and the file name\n",
      "       doesn't  specify  an explicit directory or drive (for instance, doesn't\n",
      "       contain \"/\" on Unix systems), Ghostscript tries directories in this or‐\n",
      "       der:\n",
      "\n",
      "       1.  the  directories  specified  by the -I switches in the command line\n",
      "           (see below), if any;\n",
      "\n",
      "       2.  the directories specified by the GS_LIB  environment  variable,  if\n",
      "           any;\n",
      "\n",
      "       3.  the directories specified by the GS_LIB_DEFAULT macro in the Ghost‐\n",
      "           script makefile when the executable was built.   GS_LIB_DEFAULT  is\n",
      "           \"/usr/share/ghostscript/[0-9]*.[0-9]*/lib\" on a Debian system where\n",
      "           \"[0-9]*.[0-9]*\" represents the Ghostscript version number\n",
      "\n",
      "       Each of these (GS_LIB_DEFAULT, GS_LIB, and -I parameter) may be  either\n",
      "       a single directory or a list of directories separated by \":\".\n",
      "\n",
      "ENVIRONMENT\n",
      "       GS_OPTIONS\n",
      "              String  of  options  to be processed before the command line op‐\n",
      "              tions\n",
      "\n",
      "       GS_DEVICE\n",
      "              Used to specify an output device\n",
      "\n",
      "       GS_FONTPATH\n",
      "              Path names used to search for fonts\n",
      "\n",
      "       GS_LIB Path names for initialization files and fonts\n",
      "\n",
      "       TEMP   Where temporary files are made\n",
      "\n",
      "X RESOURCES\n",
      "       Ghostscript, or more properly the X11 display  device,  looks  for  the\n",
      "       following resources under the program name \"Ghostscript\":\n",
      "\n",
      "       borderWidth\n",
      "              The border width in pixels (default = 1).\n",
      "\n",
      "       borderColor\n",
      "              The name of the border color (default = black).\n",
      "\n",
      "       geometry\n",
      "              The window size and placement, WxH+X+Y (default is NULL).\n",
      "\n",
      "       xResolution\n",
      "              The  number  of  x  pixels  per  inch  (default is computed from\n",
      "              WidthOfScreen and WidthMMOfScreen).\n",
      "\n",
      "       yResolution\n",
      "              The number of y  pixels  per  inch  (default  is  computed  from\n",
      "              HeightOfScreen and HeightMMOfScreen).\n",
      "\n",
      "       useBackingPixmap\n",
      "              Determines  whether  backing store is to be used for saving dis‐\n",
      "              play window (default = true).\n",
      "\n",
      "       See the usage document for a more complete list of resources.   To  set\n",
      "       these  resources on Unix, put them in a file such as \"~/.Xresources\" in\n",
      "       the following form:\n",
      "\n",
      "            Ghostscript*geometry:     612x792-0+0\n",
      "            Ghostscript*xResolution: 72\n",
      "            Ghostscript*yResolution: 72\n",
      "\n",
      "       Then merge these resources into the X server's resource database:\n",
      "\n",
      "            % xrdb -merge ~/.Xresources\n",
      "\n",
      "SEE ALSO\n",
      "       The various Ghostscript document files (above), especially Use.htm.  On\n",
      "       Debian you may need to install ghostscript-doc before reading the docu‐\n",
      "       mentation.\n",
      "\n",
      "BUGS\n",
      "       See   http://bugs.ghostscript.com/   and   the   Usenet   news    group\n",
      "       comp.lang.postscript.\n",
      "\n",
      "VERSION\n",
      "       This document was last revised for Ghostscript version 9.27.\n",
      "\n",
      "AUTHOR\n",
      "       Artifex  Software,  Inc.  are  the  primary maintainers of Ghostscript.\n",
      "       Russell J. Lang, gsview at ghostgum.com.au, is the author  of  most  of\n",
      "       the MS Windows code in Ghostscript.\n",
      "\n",
      "9.27                             4 April 2019                            GS(1)\n"
     ]
    }
   ],
   "source": [
    "!man gs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "%!PS-Adobe-3.0\n",
      "%%Creator: groff version 1.22.4\n",
      "%%CreationDate: Wed Oct 28 20:11:56 2020\n",
      "%%DocumentNeededResources: font Times-Roman\n",
      "%%+ font Times-Bold\n",
      "%%+ font Times-Italic\n",
      "%%DocumentSuppliedResources: procset grops 1.22 4\n",
      "%%Pages: 6\n",
      "%%PageOrder: Ascend\n",
      "%%DocumentMedia: Default 595 842 0 () ()\n",
      "%%Orientation: Portrait\n",
      "%%EndComments\n",
      "%%BeginDefaults\n",
      "%%PageMedia: Default\n",
      "%%EndDefaults\n",
      "%%BeginProlog\n",
      "%%BeginResource: procset grops 1.22 4\n",
      "%!PS-Adobe-3.0 Resource-ProcSet\n",
      "/setpacking where{\n",
      "pop\n",
      "currentpacking\n",
      "true setpacking\n",
      "}if\n",
      "/grops 120 dict dup begin\n",
      "/SC 32 def\n",
      "/A/show load def\n",
      "/B{0 SC 3 -1 roll widthshow}bind def\n",
      "/C{0 exch ashow}bind def\n",
      "/D{0 exch 0 SC 5 2 roll awidthshow}bind def\n",
      "/E{0 rmoveto show}bind def\n",
      "/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def\n",
      "/G{0 rmoveto 0 exch ashow}bind def\n",
      "/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def\n",
      "/I{0 exch rmoveto show}bind def\n",
      "/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def\n",
      "/K{0 exch rmoveto 0 exch ashow}bind def\n",
      "/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def\n",
      "/M{rmoveto show}bind def\n",
      "/N{rmoveto 0 SC 3 -1 roll widthshow}bind def\n",
      "/O{rmoveto 0 exch ashow}bind def\n",
      "/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def\n",
      "/Q{moveto show}bind def\n",
      "/R{moveto 0 SC 3 -1 roll widthshow}bind def\n",
      "/S{moveto 0 exch ashow}bind def\n",
      "/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def\n",
      "/SF{\n",
      "findfont exch\n",
      "[exch dup 0 exch 0 exch neg 0 0]makefont\n",
      "dup setfont\n",
      "[exch/setfont cvx]cvx bind def\n",
      "}bind def\n",
      "/MF{\n",
      "findfont\n",
      "[5 2 roll\n",
      "0 3 1 roll\n",
      "neg 0 0]makefont\n",
      "dup setfont\n",
      "[exch/setfont cvx]cvx bind def\n",
      "}bind def\n",
      "/level0 0 def\n",
      "/RES 0 def\n",
      "/PL 0 def\n",
      "/LS 0 def\n",
      "/MANUAL{\n",
      "statusdict begin/manualfeed true store end\n",
      "}bind def\n",
      "/PLG{\n",
      "gsave newpath clippath pathbbox grestore\n",
      "exch pop add exch pop\n",
      "}bind def\n",
      "/BP{\n",
      "/level0 save def\n",
      "1 setlinecap\n",
      "1 setlinejoin\n",
      "DEFS/BPhook known{DEFS begin BPhook end}if\n",
      "72 RES div dup scale\n",
      "LS{\n",
      "90 rotate\n",
      "}{\n",
      "0 PL translate\n",
      "}ifelse\n",
      "1 -1 scale\n",
      "}bind def\n",
      "/EP{\n",
      "level0 restore\n",
      "showpage\n",
      "}def\n",
      "/DA{\n",
      "newpath arcn stroke\n",
      "}bind def\n",
      "/SN{\n",
      "transform\n",
      ".25 sub exch .25 sub exch\n",
      "round .25 add exch round .25 add exch\n",
      "itransform\n",
      "}bind def\n",
      "/DL{\n",
      "SN\n",
      "moveto\n",
      "SN\n",
      "lineto stroke\n",
      "}bind def\n",
      "/DC{\n",
      "newpath 0 360 arc closepath\n",
      "}bind def\n",
      "/TM matrix def\n",
      "/DE{\n",
      "TM currentmatrix pop\n",
      "translate scale newpath 0 0 .5 0 360 arc closepath\n",
      "TM setmatrix\n",
      "}bind def\n",
      "/RC/rcurveto load def\n",
      "/RL/rlineto load def\n",
      "/ST/stroke load def\n",
      "/MT/moveto load def\n",
      "/CL/closepath load def\n",
      "/Fr{\n",
      "setrgbcolor fill\n",
      "}bind def\n",
      "/setcmykcolor where{\n",
      "pop\n",
      "/Fk{\n",
      "setcmykcolor fill\n",
      "}bind def\n",
      "}if\n",
      "/Fg{\n",
      "setgray fill\n",
      "}bind def\n",
      "/FL/fill load def\n",
      "/LW/setlinewidth load def\n",
      "/Cr/setrgbcolor load def\n",
      "/setcmykcolor where{\n",
      "pop\n",
      "/Ck/setcmykcolor load def\n",
      "}if\n",
      "/Cg/setgray load def\n",
      "/RE{\n",
      "findfont\n",
      "dup maxlength 1 index/FontName known not{1 add}if dict begin\n",
      "{\n",
      "1 index/FID ne\n",
      "2 index/UniqueID ne\n",
      "and\n",
      "{def}{pop pop}ifelse\n",
      "}forall\n",
      "/Encoding exch def\n",
      "dup/FontName exch def\n",
      "currentdict end definefont pop\n",
      "}bind def\n",
      "/DEFS 0 def\n",
      "/EBEGIN{\n",
      "moveto\n",
      "DEFS begin\n",
      "}bind def\n",
      "/EEND/end load def\n",
      "/CNT 0 def\n",
      "/level1 0 def\n",
      "/PBEGIN{\n",
      "/level1 save def\n",
      "translate\n",
      "div 3 1 roll div exch scale\n",
      "neg exch neg exch translate\n",
      "0 setgray\n",
      "0 setlinecap\n",
      "1 setlinewidth\n",
      "0 setlinejoin\n",
      "10 setmiterlimit\n",
      "[]0 setdash\n",
      "/setstrokeadjust where{\n",
      "pop\n",
      "false setstrokeadjust\n",
      "}if\n",
      "/setoverprint where{\n",
      "pop\n",
      "false setoverprint\n",
      "}if\n",
      "newpath\n",
      "/CNT countdictstack def\n",
      "userdict begin\n",
      "/showpage{}def\n",
      "/setpagedevice{}def\n",
      "mark\n",
      "}bind def\n",
      "/PEND{\n",
      "cleartomark\n",
      "countdictstack CNT sub{end}repeat\n",
      "level1 restore\n",
      "}bind def\n",
      "end def\n",
      "/setpacking where{\n",
      "pop\n",
      "setpacking\n",
      "}if\n",
      "%%EndResource\n",
      "%%EndProlog\n",
      "%%BeginSetup\n",
      "%%BeginFeature: *PageSize Default\n",
      "<< /PageSize [ 595 842 ] /ImagingBBox null >> setpagedevice\n",
      "%%EndFeature\n",
      "%%IncludeResource: font Times-Roman\n",
      "%%IncludeResource: font Times-Bold\n",
      "%%IncludeResource: font Times-Italic\n",
      "grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72\n",
      "def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron\n",
      "/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef\n",
      "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
      "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n",
      "/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent\n",
      "/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen\n",
      "/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon\n",
      "/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O\n",
      "/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex\n",
      "/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\n",
      "/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft\n",
      "/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl\n",
      "/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut\n",
      "/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash\n",
      "/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen\n",
      "/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft\n",
      "/logicalnot/minus/registered/macron/degree/plusminus/twosuperior\n",
      "/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior\n",
      "/ordmasculine/guilsinglright/onequarter/onehalf/threequarters\n",
      "/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE\n",
      "/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n",
      "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n",
      "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn\n",
      "/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla\n",
      "/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis\n",
      "/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash\n",
      "/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def\n",
      "/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE\n",
      "/Times-Roman@0 ENC0/Times-Roman RE\n",
      "%%EndSetup\n",
      "%%Page: 1 1\n",
      "%%BeginPageSetup\n",
      "BP\n",
      "%%EndPageSetup\n",
      "/F0 10/Times-Roman@0 SF 184.005(GS\\(1\\) Ghostscript GS\\(1\\))72 48 R/F1\n",
      "10.95/Times-Bold@0 SF -.219(NA)72 84 S(ME).219 E F0\n",
      "(gs \\255 Ghostscript \\(PostScript and PDF language interpreter and pre)\n",
      "108 96 Q(vie)-.25 E(wer\\))-.25 E F1(SYNOPSIS)72 112.8 Q/F2 10\n",
      "/Times-Bold@0 SF(gs)108 124.8 Q F0([)2.5 E/F3 10/Times-Italic@0 SF\n",
      "(options)2.5 E F0 2.5(][)2.5 G F3(\\214les)A F0 2.5(].)2.5 G(..)-2.5 E F1\n",
      "(DESCRIPTION)72 141.6 Q F0(The)108 153.6 Q F2(gs)4.175 E F0 1.675\n",
      "(command in)4.175 F -.2(vo)-.4 G -.1(ke).2 G(s).1 E F2(Ghostscript)4.175\n",
      "E F0 4.175(,a)C 4.175(ni)-4.175 G 1.675(nterpreter of Adobe Systems')\n",
      "-4.175 F F2 -.2(Po)4.175 G(stScript).2 E F0 1.675(\\(tm\\) and)B F2 -.2\n",
      "(Po)4.175 G(rtable).2 E .875(Document F)108 165.6 R(ormat)-.25 E F0 .875\n",
      "(\\(PDF\\) languages.)3.375 F F2(gs)5.875 E F0 .875\n",
      "(reads \"\\214les\" in sequence and e)3.375 F -.15(xe)-.15 G .875\n",
      "(cutes them as Ghostscript pro-).15 F .071(grams. After doing this, it \\\n",
      "reads further input from the standard input stream \\(normally the k)108\n",
      "177.6 R -.15(ey)-.1 G .07(board\\), inter).15 F(-)-.2 E .693\n",
      "(preting each line separately and output to an output de)108 189.6 R\n",
      ".694(vice \\(may be a \\214le or an X11 windo)-.25 F 3.194(wp)-.25 G(re)\n",
      "-3.194 E(vie)-.25 E 1.994 -.65(w, s)-.25 H(ee).65 E(belo)108 201.6 Q\n",
      ".353(w\\). The interpreter e)-.25 F .352(xits gracefully when it encount\\\n",
      "ers the \"quit\" command \\(either in a \\214le or from the)-.15 F -.1(ke)\n",
      "108 213.6 S(yboard\\), at end-of-\\214le, or at an interrupt signal \\(suc\\\n",
      "h as Control-C at the k)-.05 E -.15(ey)-.1 G(board\\).).15 E .414\n",
      "(The interpreter recognizes man)108 230.4 R 2.914(yo)-.15 G .414\n",
      "(ption switches, some of which are described belo)-2.914 F 1.714 -.65\n",
      "(w. P)-.25 H .414(lease see the usage).65 F .139\n",
      "(documentation for complete information. Switches may appear an)108\n",
      "242.4 R .138(ywhere in the command line and apply to)-.15 F .188\n",
      "(all \\214les thereafter)108 254.4 R 5.188(.I)-.55 G -1.9 -.4(nv o)-5.188\n",
      "H .189(king Ghostscript with the).4 F F2<ad68>2.689 E F0(or)2.689 E F2\n",
      "<ad3f>2.689 E F0 .189(switch produces a message which sho)2.689 F .189\n",
      "(ws se)-.25 F -.15(ve)-.25 G(ral).15 E 1.302\n",
      "(useful switches, all the de)108 266.4 R 1.301(vices kno)-.25 F 1.301\n",
      "(wn to that e)-.25 F -.15(xe)-.15 G 1.301\n",
      "(cutable, and the search path for fonts; on Unix it also).15 F(sho)108\n",
      "278.4 Q(ws the location of detailed documentation.)-.25 E .891\n",
      "(Ghostscript may be b)108 295.2 R .892(uilt to use man)-.2 F 3.392(yd)\n",
      "-.15 G(if)-3.392 E .892(ferent output de)-.25 F 3.392(vices. T)-.25 F\n",
      "3.392(os)-.8 G .892(ee which de)-3.392 F .892(vices your e)-.25 F -.15\n",
      "(xe)-.15 G .892(cutable in-).15 F(cludes, run \")108 307.2 Q F2(gs -h)A\n",
      "F0(\".)A .37(Unless you specify a particular de)108 324 R .37(vice, Ghos\\\n",
      "tscript normally opens the \\214rst one of those and directs output)-.25\n",
      "F(to it.)108 336 Q .572(If you ha)108 352.8 R .872 -.15(ve i)-.2 H .572\n",
      "(nstalled the ghostscript-x Debian package and are under X, the def).15\n",
      "F .572(ault de)-.1 F .573(vice is an X11 win-)-.25 F(do)108 364.8 Q\n",
      "3.399(w\\()-.25 G(pre)-3.399 E(vie)-.25 E .898\n",
      "(wer\\), else ghostscript will use the bbox de)-.25 F .898\n",
      "(vice and print on stdout the dimension of the post-)-.25 F\n",
      "(script \\214le.)108 376.8 Q\n",
      "(So if the \\214rst one in the list is the one you w)108 393.6 Q\n",
      "(ant to use, just issue the command)-.1 E(gs my\\214le.ps)144 410.4 Q\n",
      "-1.1(Yo)108 427.2 S 2.5(uc)1.1 G(an also check the set of a)-2.5 E -.25\n",
      "(va)-.2 G(ilable de).25 E(vices from within Ghostscript: in)-.25 E -.2\n",
      "(vo)-.4 G .2 -.1(ke G).2 H(hostscript and type).1 E(de)144 444 Q\n",
      "(vicenames ==)-.25 E -.2(bu)108 460.8 S 2.802(tt).2 G .302\n",
      "(he \\214rst de)-2.802 F .302\n",
      "(vice on the resulting list may not be the def)-.25 F .302(ault de)-.1 F\n",
      ".302(vice you determine with \")-.25 F F2 .302(gs -h)B F0 2.802(\". T)B\n",
      "2.802(os)-.8 G(pec-)-2.802 E(ify \"AbcXyz\" as the initial output de)108\n",
      "472.8 Q(vice, include the switch)-.25 E(\\255sDEVICE=AbcXyz)144 489.6 Q\n",
      "-.15(Fo)108 506.4 S 2.5(re).15 G\n",
      "(xample, for output to an Epson printer you might use the command)-2.65\n",
      "E(gs \\255sDEVICE=epson my\\214le.ps)144 523.2 Q .746(The \"\\255sDEVICE=\" \\\n",
      "switch must precede the \\214rst mention of a \\214le to print, and only \\\n",
      "the switch')108 540 R 3.245<738c>-.55 G .745(rst use)-3.245 F(has an)108\n",
      "552 Q 2.5(ye)-.15 G -.25(ff)-2.5 G(ect.).25 E(Finally)108 568.8 Q 3.452\n",
      "(,y)-.65 G .952(ou can specify a def)-3.452 F .953(ault de)-.1 F .953\n",
      "(vice in the en)-.25 F .953(vironment v)-.4 F(ariable)-.25 E F2\n",
      "(GS_DEVICE)3.453 E F0 5.953(.T)C .953(he order of prece-)-5.953 F .637\n",
      "(dence for these alternati)108 580.8 R -.15(ve)-.25 G 3.137(sf).15 G\n",
      ".636(rom highest to lo)-3.137 F .636(west \\(Ghostscript uses the de)-.25\n",
      "F .636(vice de\\214ned highest in the list\\))-.25 F(is:)108 592.8 Q .473\n",
      "(Some de)108 609.6 R .473(vices can support dif)-.25 F .473\n",
      "(ferent resolutions \\(densities\\).)-.25 F 2.073 -.8(To s)5.473 H .474\n",
      "(pecify the resolution on such a printer).8 F 2.974(,u)-.4 G(se)-2.974 E\n",
      "(the \"\\255r\" switch:)108 621.6 Q(gs \\255sDEVICE=<de)144 638.4 Q\n",
      "(vice> \\255r<xres>x<yres>)-.25 E -.15(Fo)108 655.2 S 2.5(re).15 G\n",
      "(xample, on a 9-pin Epson-compatible printer)-2.65 E 2.5(,y)-.4 G\n",
      "(ou get the lo)-2.5 E(west-density \\(f)-.25 E(astest\\) mode with)-.1 E\n",
      "(gs \\255sDEVICE=epson \\255r60x72)144 672 Q\n",
      "(and the highest-density \\(best output quality\\) mode with)108 688.8 Q\n",
      "(gs \\255sDEVICE=epson \\255r240x72.)144 705.6 Q .478\n",
      "(If you select a printer as the output de)108 722.4 R .478\n",
      "(vice, Ghostscript also allo)-.25 F .477\n",
      "(ws you to choose where Ghostscript sends)-.25 F 188.445(9.27 4)72 768 R\n",
      "(April 2019)2.5 E(1)203.445 E 0 Cg EP\n",
      "%%Page: 2 2\n",
      "%%BeginPageSetup\n",
      "BP\n",
      "%%EndPageSetup\n",
      "/F0 10/Times-Roman@0 SF 184.005(GS\\(1\\) Ghostscript GS\\(1\\))72 48 R .544\n",
      "(the output \\255\\255 on Unix systems, usually to a temporary \\214le.)108\n",
      "84 R 2.144 -.8(To s)5.544 H .544\n",
      "(end the output to a \\214le \"foo.xyz\", use the).8 F(switch)108 96 Q\n",
      "(\\255sOutputFile=foo.xyz)144 112.8 Q -1.1(Yo)108 129.6 S 3.644(um)1.1 G\n",
      "1.144(ight w)-3.644 F 1.144(ant to print each page separately)-.1 F\n",
      "6.144(.T)-.65 G 3.644(od)-6.944 G 3.644(ot)-3.644 G 1.143\n",
      "(his, send the output to a series of \\214les \"foo1.xyz,)-3.644 F(foo2.x\\\n",
      "yz, ...\" using the \"\\255sOutputFile=\" switch with \"%d\" in a \\214lename \\\n",
      "template:)108 141.6 Q(\\255sOutputFile=foo%d.xyz)144 158.4 Q .004\n",
      "(Each resulting \\214le recei)108 175.2 R -.15(ve)-.25 G 2.504(so).15 G\n",
      ".005(ne page of output, and the \\214les are numbered in sequence.)-2.504\n",
      "F .005(\"%d\" is a printf for)5.005 F(-)-.2 E\n",
      "(mat speci\\214cation; you can also use a v)108 187.2 Q(ariant lik)-.25 E\n",
      "2.5(e\")-.1 G(%02d\".)-2.5 E -1.1(Yo)108 204 S 3.385(uc)1.1 G .885\n",
      "(an also send output to a pipe.)-3.385 F -.15(Fo)5.885 G 3.385(re).15 G\n",
      ".885(xample, to pipe output to the \")-3.535 F/F1 10/Times-Bold@0 SF(lpr)\n",
      "A F0 3.384(\"c)C .884(ommand \\(which, on man)-3.384 F(y)-.15 E\n",
      "(Unix systems, directs it to a printer\\), use the option)108 216 Q\n",
      "(\\255sOutputFile=%pipe%lpr)144 232.8 Q -1.1(Yo)108 249.6 S 2.5(uc)1.1 G\n",
      "(an also send output to standard output:)-2.5 E(\\255sOutputFile=\\255)144\n",
      "266.4 Q(or)108 278.4 Q(\\255sOutputFile=%stdout%)144 290.4 Q .204\n",
      "(In this case you must also use the)108 307.2 R F1<ad71>2.704 E F0 .204\n",
      "(switch, to pre)2.704 F -.15(ve)-.25 G .205\n",
      "(nt Ghostscript from writing messages to standard out-).15 F(put.)108\n",
      "319.2 Q 1.6 -.8(To s)108 336 T\n",
      "(elect a speci\\214c paper size, use the command line switch).8 E(-sP)144\n",
      "352.8 Q(APERSIZE=<paper_size>)-.92 E(for instance)108 369.6 Q(-sP)144\n",
      "386.4 Q(APERSIZE=a4)-.92 E(or)108 398.4 Q(-sP)144 410.4 Q(APERSIZE=le)\n",
      "-.92 E -.05(ga)-.15 G(l).05 E .362(Most ISO and US paper sizes are reco\\\n",
      "gnized. See the usage documentation for a full list, or the de\\214nitio\\\n",
      "ns)108 427.2 R(in the initialization \\214le \"gs_statd.ps\".)108 439.2 Q\n",
      ".017(Ghostscript can do man)108 456 R 2.517(yt)-.15 G .018\n",
      "(hings other than print or vie)-2.517 F 2.518(wP)-.25 G .018\n",
      "(ostScript and PDF \\214les.)-2.518 F -.15(Fo)5.018 G 2.518(re).15 G .018\n",
      "(xample, if you w)-2.668 F(ant)-.1 E 1.018(to kno)108 468 R 3.517(wt)\n",
      "-.25 G 1.017\n",
      "(he bounding box of a PostScript \\(or EPS\\) \\214le, Ghostscript pro)\n",
      "-3.517 F 1.017(vides a special \"de)-.15 F 1.017(vice\" that just)-.25 F\n",
      "(prints out this information.)108 480 Q -.15(Fo)108 496.8 S 2.5(re).15 G\n",
      "(xample, using one of the e)-2.65 E(xample \\214les distrib)-.15 E\n",
      "(uted with Ghostscript,)-.2 E(gs \\255sDEVICE=bbox golfer)144 513.6 Q\n",
      "(.ps)-.55 E(prints out)108 530.4 Q(%%BoundingBox: 0 25 583 732)144 547.2\n",
      "Q(%%HiResBoundingBox: 0.808497 25.009496 582.994503 731.809445)144 559.2\n",
      "Q/F2 10.95/Times-Bold@0 SF(OPTIONS)72 576 Q F1<adad>108 588 Q/F3 10\n",
      "/Times-Italic@0 SF(\\214lename ar)2.5 E(g1 ...)-.37 E F0 -.8(Ta)144 600 S\n",
      "-.1(ke).8 G 3.349(st).1 G .849(he ne)-3.349 F .849(xt ar)-.15 F .849\n",
      "(gument as a \\214le name as usual, b)-.18 F .85(ut tak)-.2 F .85\n",
      "(es all remaining ar)-.1 F .85(guments \\(e)-.18 F -.15(ve)-.25 G 3.35\n",
      "(ni).15 G 3.35(ft)-3.35 G(he)-3.35 E(y)-.15 E(ha)144 612 Q 1.91 -.15\n",
      "(ve t)-.2 H 1.609(he syntactic form of switches\\) and de\\214nes the nam\\\n",
      "e \"ARGUMENTS\" in \"userdict\" \\(not).15 F .318\n",
      "(\"systemdict\"\\) as an array of those strings,)144 624 R F1(bef)2.819 E\n",
      "(or)-.25 E(e)-.18 E F0 .319(running the \\214le.)2.819 F .319\n",
      "(When Ghostscript \\214nishes e)5.319 F -.15(xe)-.15 G(-).15 E\n",
      "(cuting the \\214le, it e)144 636 Q(xits back to the shell.)-.15 E F1\n",
      "<ad44>108 652.8 Q F3(name).36 E F1(=).18 E F3(tok).13 E(en)-.1 E F1\n",
      "<ad64>108 664.8 Q F3(name).36 E F1(=).18 E F3(tok).13 E(en)-.1 E F0 .366\n",
      "(De\\214ne a name in \"systemdict\" with the gi)144 676.8 R -.15(ve)-.25 G\n",
      "2.866(nd).15 G 2.866(e\\214nition. The)-2.866 F(tok)2.866 E .365\n",
      "(en must be e)-.1 F .365(xactly one tok)-.15 F .365(en \\(as)-.1 F\n",
      "(de\\214ned by the \"tok)144 688.8 Q\n",
      "(en\" operator\\) and may contain no whitespace.)-.1 E F1<ad44>108 705.6 Q\n",
      "F3(name).36 E F0 188.445(9.27 4)72 768 R(April 2019)2.5 E(2)203.445 E 0\n",
      "Cg EP\n",
      "%%Page: 3 3\n",
      "%%BeginPageSetup\n",
      "BP\n",
      "%%EndPageSetup\n",
      "/F0 10/Times-Roman@0 SF 184.005(GS\\(1\\) Ghostscript GS\\(1\\))72 48 R/F1\n",
      "10/Times-Bold@0 SF<ad64>108 84 Q/F2 10/Times-Italic@0 SF(name).36 E F0\n",
      "(De\\214ne a name in \"systemdict\" with v)144 96 Q(alue=null.)-.25 E F1\n",
      "<ad53>108 112.8 Q F2(name).36 E F1(=).18 E F2(string).34 E F1<ad73>108\n",
      "124.8 Q F2(name).36 E F1(=).18 E F2(string).34 E F0 .444\n",
      "(De\\214ne a name in \"systemdict\" with a gi)144 136.8 R -.15(ve)-.25 G\n",
      "2.944(ns).15 G .444(tring as v)-2.944 F 2.944(alue. This)-.25 F .444\n",
      "(is dif)2.944 F .444(ferent from)-.25 F F1<ad64>2.944 E F0 5.445(.F)C\n",
      ".445(or e)-5.595 F(xam-)-.15 E(ple,)144 148.8 Q F1(\\255dname=35)2.5 E F0\n",
      "(is equi)2.5 E -.25(va)-.25 G(lent to the program fragment).25 E\n",
      "(/name 35 def)180 160.8 Q(whereas)144 172.8 Q F1(\\255sname=35)2.5 E F0\n",
      "(is equi)2.5 E -.25(va)-.25 G(lent to).25 E(/name \\(35\\) def)180 184.8 Q\n",
      "F1<ad50>108 201.6 Q F0(Mak)144 201.6 Q .157(es Ghostscript to look \\214\\\n",
      "rst in the current directory for library \\214les.)-.1 F .156(By def)\n",
      "5.156 F .156(ault, Ghostscript no)-.1 F .523\n",
      "(longer looks in the current directory)144 213.6 R 3.023(,u)-.65 G .523\n",
      "(nless, of course, the \\214rst e)-3.023 F .524\n",
      "(xplicitly supplied directory is \".\")-.15 F(in)144 225.6 Q F1(-I)3.314 E\n",
      "F0 5.813(.S)C .813(ee also the)-5.813 F F1(INITIALIZA)3.313 E .813\n",
      "(TION FILES)-.95 F F0 .813(section belo)3.313 F 2.113 -.65(w, a)-.25 H\n",
      ".813(nd b).65 F(undled)-.2 E F1(Use.htm)3.313 E F0 .813(for detailed)\n",
      "3.313 F(discussion on search paths and ho)144 237.6 Q 2.5(wG)-.25 G\n",
      "(hostcript \\214nds \\214les.)-2.5 E F1<ad71>108 254.4 Q F0\n",
      "(Quiet startup: suppress normal startup messages, and also do the equi)\n",
      "144 254.4 Q -.25(va)-.25 G(lent of).25 E F1(\\255dQ)2.5 E(UIET)-.1 E F0\n",
      "(.)A F1<ad67>108 271.2 Q F2(number1).36 E F1(x)A F2(number2).36 E F0\n",
      "(Equi)144 283.2 Q -.25(va)-.25 G 1.915(lent to).25 F F1\n",
      "(\\255dDEVICEWIDTH=)4.415 E F2(number1)A F0(and)4.416 E F1\n",
      "(\\255dDEVICEHEIGHT=)4.416 E F2(number2)A F0 6.916(.T)C 1.916(his is for)\n",
      "-6.916 F .353(the bene\\214t of de)144 295.2 R .353\n",
      "(vices \\(such as X11 windo)-.25 F .352(ws\\) that require \\(or allo)-.25\n",
      "F .352(w\\) width and height to be speci-)-.25 F(\\214ed.)144 307.2 Q F1\n",
      "<ad72>108 324 Q F2(number).36 E F1<ad72>108 336 Q F2(number1).36 E F1(x)\n",
      "A F2(number2).36 E F0(Equi)144 348 Q -.25(va)-.25 G 1.337(lent to).25 F\n",
      "F1(\\255dDEVICEXRESOLUTION=)3.837 E F2(number1)A F0(and)3.838 E F1\n",
      "(\\255dDEVICEYRESOLUTION=)3.838 E F2(num-)A(ber2)144 360 Q F0 5.338(.T)C\n",
      ".337(his is for the bene\\214t of de)-5.338 F .337\n",
      "(vices such as printers that support multiple X and Y resolutions.)-.25\n",
      "F(If only one number is gi)144 372 Q -.15(ve)-.25 G\n",
      "(n, it is used for both X and Y resolutions.).15 E F1<ad49>108 388.8 Q\n",
      "F2(dir).35 E(ectories)-.37 E F0(Adds the designated list of directories\\\n",
      " at the head of the search path for library \\214les.)144 400.8 Q F1<ad>\n",
      "108 417.6 Q F0 .268(This is not really a switch, b)144 417.6 R .268(ut \\\n",
      "indicates to Ghostscript that standard input is coming from a \\214le or)\n",
      "-.2 F 2.763(ap)144 429.6 S .263(ipe and not interacti)-2.763 F -.15(ve)\n",
      "-.25 G .263(ly from the command line.).15 F .262\n",
      "(Ghostscript reads from standard input until it)5.263 F .988\n",
      "(reaches end-of-\\214le, e)144 441.6 R -.15(xe)-.15 G .988(cuting it lik)\n",
      ".15 F 3.488(ea)-.1 G 1.288 -.15(ny o)-3.488 H .989\n",
      "(ther \\214le, and then continues with processing the com-).15 F .345\n",
      "(mand line.)144 453.6 R .345\n",
      "(When the command line has been entirely processed, Ghostscript e)5.345\n",
      "F .345(xits rather than go-)-.15 F(ing into its interacti)144 465.6 Q .3\n",
      "-.15(ve m)-.25 H(ode.).15 E 1.074\n",
      "(Note that the normal initialization \\214le \"gs_init.ps\" mak)108 482.4 R\n",
      "1.074(es \"systemdict\" read-only)-.1 F 3.574(,s)-.65 G 3.575(ot)-3.574 G\n",
      "1.075(he v)-3.575 F 1.075(alues of names)-.25 F .601(de\\214ned with)108\n",
      "494.4 R F1<ad44>3.101 E F0(,)A F1<ad64>3.101 E F0(,)A F1<ad53>3.101 E F0\n",
      "3.101(,o)C(r)-3.101 E F1<ad73>3.101 E F0 .601\n",
      "(cannot be changed \\(although, of course, the)3.101 F 3.1(yc)-.15 G .6\n",
      "(an be superseded by de\\214ni-)-3.1 F\n",
      "(tions in \"userdict\" or other dictionaries.\\))108 506.4 Q/F3 10.95\n",
      "/Times-Bold@0 SF(SPECIAL N)72 523.2 Q(AMES)-.219 E F1(\\255dNOCA)108\n",
      "535.2 Q(CHE)-.55 E F0(Disables character caching.)144 547.2 Q\n",
      "(Useful only for deb)5 E(ugging.)-.2 E F1(\\255dNOBIND)108 564 Q F0\n",
      "(Disables the \"bind\" operator)144 576 Q 5(.U)-.55 G(seful only for deb)\n",
      "-5 E(ugging.)-.2 E F1(\\255dNODISPLA)108 592.8 Q(Y)-1 E F0\n",
      "(Suppresses the normal initialization of the output de)144 604.8 Q 2.5\n",
      "(vice. This)-.25 F(may be useful when deb)2.5 E(ugging.)-.2 E F1\n",
      "(\\255dNOP)108 621.6 Q -.5(AU)-.74 G(SE).5 E F0 1.144\n",
      "(Disables the prompt and pause at the end of each page.)144 633.6 R\n",
      "1.144(This may be desirable for applications)6.144 F\n",
      "(where another program is dri)144 645.6 Q(ving Ghostscript.)-.25 E F1\n",
      "(\\255dNOPLA)108 662.4 Q(TFONTS)-.95 E F0 .187(Disables the use of fonts\\\n",
      " supplied by the underlying platform \\(for instance X W)144 674.4 R\n",
      "(indo)-.4 E .187(ws\\). This may)-.25 F\n",
      "(be needed if the platform fonts look undesirably dif)144 686.4 Q\n",
      "(ferent from the scalable fonts.)-.25 E F1(\\255dSAFER)108 703.2 Q F0\n",
      "1.913(Restricts \\214le operations the job can perform.)144 715.2 R 1.914\n",
      "(Strongly recommended for spoolers, con)6.914 F -.15(ve)-.4 G(rsion).15\n",
      "E 1.728(scripts or other sensiti)144 727.2 R 2.028 -.15(ve e)-.25 H -.4\n",
      "(nv).15 G 1.727\n",
      "(ironments where a badly written or malicious PostScript program).4 F\n",
      "188.445(9.27 4)72 768 R(April 2019)2.5 E(3)203.445 E 0 Cg EP\n",
      "%%Page: 4 4\n",
      "%%BeginPageSetup\n",
      "BP\n",
      "%%EndPageSetup\n",
      "/F0 10/Times-Roman@0 SF 184.005(GS\\(1\\) Ghostscript GS\\(1\\))72 48 R\n",
      "(code must be pre)144 84 Q -.15(ve)-.25 G\n",
      "(nted from changing important \\214les.).15 E/F1 10/Times-Bold@0 SF\n",
      "(\\255dWRITESYSTEMDICT)108 100.8 Q F0(Lea)144 112.8 Q -.15(ve)-.2 G 4.336\n",
      "(s\").15 G 1.836(systemdict\" writable.)-4.336 F 1.837\n",
      "(This is necessary when running special utility programs, b)6.836 F\n",
      "1.837(ut is)-.2 F(strongly discouraged as it bypasses normal Postscript\\\n",
      " security measures.)144 124.8 Q F1(\\255sDEVICE=)108 141.6 Q/F2 10\n",
      "/Times-Italic@0 SF(de).35 E(vice)-.15 E F0\n",
      "(Selects an alternate initial output de)144 153.6 Q\n",
      "(vice, as described abo)-.25 E -.15(ve)-.15 G(.).15 E F1\n",
      "(\\255sOutputFile=)108 170.4 Q F2(\\214lename)1.91 E F0(Selects an altern\\\n",
      "ate output \\214le \\(or pipe\\) for the initial output de)144 182.4 Q\n",
      "(vice, as described abo)-.25 E -.15(ve)-.15 G(.).15 E/F3 10.95\n",
      "/Times-Bold@0 SF(SAFER MODE)72 199.2 Q F0(The)108 211.2 Q F1(\\255dSAFER)\n",
      "4.261 E F0 1.761(option disables the \"delete\\214le\" and \"rename\\214le\" \\\n",
      "operators and prohibits opening piped)4.261 F .067(commands \\(\"%pipe%)\n",
      "108 223.2 R F2(cmd)A F0 .067(\"\\). Only \"%stdout\" and \"%stderr\" can be o\\\n",
      "pened for writing. It also disables read-)B 1.023(ing from \\214les, e)\n",
      "108 235.2 R 1.023(xcept for \"%stdin\", \\214les gi)-.15 F -.15(ve)-.25 G\n",
      "3.523(na).15 G 3.523(sac)-3.523 G 1.023(ommand line ar)-3.523 F 1.023\n",
      "(gument, and \\214les contained in paths)-.18 F(gi)108 247.2 Q -.15(ve)\n",
      "-.25 G 2.906(nb).15 G 2.906(yL)-2.906 G(IBP)-2.906 E -1.11(AT)-.92 G\n",
      "2.906(Ha)1.11 G .406(nd FONTP)-2.906 F -1.11(AT)-.92 G 2.906(Ho)1.11 G\n",
      "2.906(rs)-2.906 G .406(peci\\214ed by the system params /F)-2.906 F .407\n",
      "(ontResourceDir and /GenericRe-)-.15 F(sourceDir)108 259.2 Q(.)-.55 E\n",
      "1.168(This mode also sets the .LockSafetyP)108 276 R 1.167\n",
      "(arams parameter of the initial output de)-.15 F 1.167\n",
      "(vice to protect ag)-.25 F 1.167(ainst pro-)-.05 F 1.54\n",
      "(grams that attempt to write to \\214les using the OutputFile de)108 288\n",
      "R 1.541(vice parameter)-.25 F 4.041(.S)-.55 G 1.541(ince the de)-4.041 F\n",
      "1.541(vice parameters)-.25 F 1.715(speci\\214ed on the command line, inc\\\n",
      "luding OutputFile, are set prior to SAFER mode, use of \"-sOutput-)108\n",
      "300 R(File=...\" on the command line is unrestricted.)108 312 Q 2.288\n",
      "(SAFER mode pre)108 328.8 R -.15(ve)-.25 G 2.289\n",
      "(nts changing the /GenericResourceDir).15 F 4.789(,/)-.4 G -.15(Fo)\n",
      "-4.789 G(ntResourceDir).15 E 4.789(,/)-.4 G(SystemP)-4.789 E(aramsP)-.15\n",
      "E(assw)-.15 E(ord,)-.1 E(and /StartJobP)108 340.8 Q(assw)-.15 E(ord.)-.1\n",
      "E .134(While SAFER mode is not the def)108 357.6 R .134\n",
      "(ault, it is the def)-.1 F .134(ault for man)-.1 F 2.634(yw)-.15 G .134\n",
      "(rapper scripts such as ps2pdf and may be)-2.634 F .535(the def)108\n",
      "369.6 R .536(ault in a subsequent release of Ghostscript.)-.1 F .536\n",
      "(Thus when running programs that need to open \\214les or)5.536 F .849\n",
      "(set restricted parameters you should pass the)108 381.6 R F1\n",
      "(\\255dNOSAFER)3.349 E F0 .848(command line option or its synon)3.349 F\n",
      "(ym)-.15 E F1(\\255dDE-)3.348 E(LA)108 393.6 Q(YSAFER)-1 E F0(.)A .071\n",
      "(When running with)108 410.4 R F1(\\255dNOSAFER)2.571 E F0 .071\n",
      "(it is possible to perform a \"sa)2.571 F -.15(ve)-.2 G 2.571(\"f).15 G\n",
      "(ollo)-2.571 E .071(wed by \".setsafe\", e)-.25 F -.15(xe)-.15 G .072\n",
      "(cute a \\214le or).15 F .841(procedure in SAFER mode, and then use \"res\\\n",
      "tore\" to return to NOSAFER mode.)108 422.4 R .841(In order to pre)5.841\n",
      "F -.15(ve)-.25 G .841(nt the).15 F(sa)108 434.4 Q .671 -.15(ve o)-.2 H\n",
      ".372(bject from being restored by the foreign \\214le or procedure, the \\\n",
      "\".runandhide\" operator should be used).15 F(to hide the sa)108 446.4 Q\n",
      ".3 -.15(ve o)-.2 H(bject from the restricted procedure.).15 E F3(FILES)\n",
      "72 463.2 Q F0 .229(The locations of man)108 475.2 R 2.729(yG)-.15 G .228\n",
      "(hostscript run-time \\214les are compiled into the e)-2.729 F -.15(xe)\n",
      "-.15 G .228(cutable when it is b).15 F 2.728(uilt. Run)-.2 F(\")2.728 E\n",
      "F1(gs)A(-h)108 487.2 Q F0 2.624(\"t)C 2.624<6f8c>-2.624 G .125(nd the lo\\\n",
      "cation of Ghostscript documentation on your system, from which you can \\\n",
      "get more details.)-2.624 F(On a Debian system the)108 499.2 Q 2.5(ya)\n",
      "-.15 G(re in)-2.5 E F1(/usr)2.5 E F0(.)A F1(/usr/shar)108 516 Q\n",
      "(e/ghostscript/[0-9]*.[0.9]*/*)-.18 E F0(Startup \\214les, utilities, an\\\n",
      "d basic font de\\214nitions \\(where [0-9]*.[0.9]* is the ghostscript v)\n",
      "144 528 Q(ersion\\))-.15 E F1(/usr/shar)108 544.8 Q(e/f)-.18 E\n",
      "(onts/type1/gsf)-.25 E(onts/*)-.25 E F0\n",
      "(More font de\\214nitions from the gsfonts package)144 556.8 Q F1\n",
      "(/usr/shar)108 573.6 Q(e/doc/ghostscript/examples/*)-.18 E F0(Ghostscri\\\n",
      "pt demonstration \\214les \\(if ghostscript-doc package is installed\\))144\n",
      "585.6 Q F1(/usr/shar)108 602.4 Q(e/doc/ghostscript/*)-.18 E F0(Di)144\n",
      "614.4 Q -.15(ve)-.25 G\n",
      "(rse document \\214les \\(may need to install ghostscript-doc package\\))\n",
      ".15 E F3(INITIALIZA)72 631.2 Q(TION FILES)-1.04 E F0 .001(When looking \\\n",
      "for the initialization \\214les \"gs_*.ps\", the \\214les related to fonts,\\\n",
      " or the \\214le for the \"run\" operator)108 643.2 R(,)-.4 E .543\n",
      "(Ghostscript \\214rst tries to open the \\214le with the name as gi)108\n",
      "655.2 R -.15(ve)-.25 G .543(n, using the current w).15 F .544\n",
      "(orking directory if no di-)-.1 F 1.196(rectory is speci\\214ed.)108\n",
      "667.2 R 1.196(If this f)6.196 F 1.196(ails, and the \\214le name doesn')\n",
      "-.1 F 3.695(ts)-.18 G 1.195(pecify an e)-3.695 F 1.195\n",
      "(xplicit directory or dri)-.15 F 1.495 -.15(ve \\()-.25 H 1.195(for in-)\n",
      ".15 F(stance, doesn')108 679.2 Q 2.5(tc)-.18 G(ontain \"/\" on Unix syste\\\n",
      "ms\\), Ghostscript tries directories in this order:)-2.5 E(1.)108 696 Q\n",
      "(the directories speci\\214ed by the)128 696 Q F1<ad49>2.5 E F0\n",
      "(switches in the command line \\(see belo)2.5 E(w\\), if an)-.25 E(y;)-.15\n",
      "E(2.)108 712.8 Q(the directories speci\\214ed by the)128 712.8 Q F1\n",
      "(GS_LIB)2.5 E F0(en)2.5 E(vironment v)-.4 E(ariable, if an)-.25 E(y;)\n",
      "-.15 E 188.445(9.27 4)72 768 R(April 2019)2.5 E(4)203.445 E 0 Cg EP\n",
      "%%Page: 5 5\n",
      "%%BeginPageSetup\n",
      "BP\n",
      "%%EndPageSetup\n",
      "/F0 10/Times-Roman@0 SF 184.005(GS\\(1\\) Ghostscript GS\\(1\\))72 48 R(3.)\n",
      "108 84 Q .387(the directories speci\\214ed by the)128 84 R/F1 10\n",
      "/Times-Bold@0 SF(GS_LIB_DEF)2.888 E -.5(AU)-.9 G -.92(LT).5 G F0 .388\n",
      "(macro in the Ghostscript mak)3.808 F .388(e\\214le when the e)-.1 F -.15\n",
      "(xe)-.15 G(-).15 E .844(cutable w)128 96 R .844(as b)-.1 F(uilt.)-.2 E\n",
      "F1(GS_LIB_DEF)5.844 E -.5(AU)-.9 G -.92(LT).5 G F0 .843\n",
      "(is \"/usr/share/ghostscript/[0-9]*.[0-9]*/lib\" on a Debian sys-)4.263 F\n",
      "(tem where \"[0-9]*.[0-9]*\" represents the Ghostscript v)128 108 Q\n",
      "(ersion number)-.15 E .437(Each of these \\()108 124.8 R F1(GS_LIB_DEF)A\n",
      "-.5(AU)-.9 G -.92(LT).5 G F0(,).92 E F1(GS_LIB)2.937 E F0 2.937(,a)C(nd)\n",
      "-2.937 E F1<ad49>2.937 E F0 .438\n",
      "(parameter\\) may be either a single directory or a list)2.937 F\n",
      "(of directories separated by \":\".)108 136.8 Q/F2 10.95/Times-Bold@0 SF\n",
      "(ENVIR)72 153.6 Q(ONMENT)-.329 E F1(GS_OPTIONS)108 165.6 Q F0\n",
      "(String of options to be processed before the command line options)144\n",
      "177.6 Q F1(GS_DEVICE)108 194.4 Q F0(Used to specify an output de)144\n",
      "206.4 Q(vice)-.25 E F1(GS_FONTP)108 223.2 Q -.95(AT)-.74 G(H).95 E F0\n",
      "-.15(Pa)144 235.2 S(th names used to search for fonts).15 E F1(GS_LIB)\n",
      "108 252 Q F0 -.15(Pa)144 264 S\n",
      "(th names for initialization \\214les and fonts).15 E F1(TEMP)108 280.8 Q\n",
      "F0(Where temporary \\214les are made)144 280.8 Q F2 2.738(XR)72 297.6 S\n",
      "(ESOURCES)-2.738 E F0 .376\n",
      "(Ghostscript, or more properly the X11 display de)108 309.6 R .375\n",
      "(vice, looks for the follo)-.25 F .375(wing resources under the program)\n",
      "-.25 F(name \"Ghostscript\":)108 321.6 Q F1(borderW)108 338.4 Q(idth)-.18\n",
      "E F0(The border width in pix)144 350.4 Q(els \\(def)-.15 E(ault = 1\\).)\n",
      "-.1 E F1(borderColor)108 367.2 Q F0(The name of the border color \\(def)\n",
      "144 379.2 Q(ault = black\\).)-.1 E F1(geometry)108 396 Q F0(The windo)144\n",
      "408 Q 2.5(ws)-.25 G(ize and placement, WxH+X+Y \\(def)-2.5 E\n",
      "(ault is NULL\\).)-.1 E F1(xResolution)108 424.8 Q F0 .932\n",
      "(The number of x pix)144 436.8 R .932(els per inch \\(def)-.15 F .932\n",
      "(ault is computed from)-.1 F F1 -.18(Wi)3.433 G(dthOfScr).18 E(een)-.18\n",
      "E F0(and)3.433 E F1 -.18(Wi)3.433 G(dthMMOf-).18 E(Scr)144 448.8 Q(een)\n",
      "-.18 E F0(\\).)A F1(yResolution)108 465.6 Q F0 .65(The number of y pix)\n",
      "144 477.6 R .649(els per inch \\(def)-.15 F .649(ault is computed from)\n",
      "-.1 F F1(HeightOfScr)3.149 E(een)-.18 E F0(and)3.149 E F1(HeightMMOf-)\n",
      "3.149 E(Scr)144 489.6 Q(een)-.18 E F0(\\).)A F1(useBackingPixmap)108\n",
      "506.4 Q F0(Determines whether backing store is to be used for sa)144\n",
      "518.4 Q(ving display windo)-.2 E 2.5(w\\()-.25 G(def)-2.5 E\n",
      "(ault = true\\).)-.1 E .327\n",
      "(See the usage document for a more complete list of resources.)108 535.2\n",
      "R 1.927 -.8(To s)5.327 H .327(et these resources on Unix, put them in).8\n",
      "F 2.5<618c>108 547.2 S(le such as \"~/.Xresources\" in the follo)-2.5 E\n",
      "(wing form:)-.25 E 16.34(Ghostscript*geometry: 612x792\\2550+0)144 564 R\n",
      "(Ghostscript*xResolution: 72)144 576 Q(Ghostscript*yResolution: 72)144\n",
      "588 Q(Then mer)108 604.8 Q(ge these resources into the X serv)-.18 E\n",
      "(er')-.15 E 2.5(sr)-.55 G(esource database:)-2.5 E 2.5(%x)144 621.6 S\n",
      "(rdb \\255mer)-2.5 E(ge ~/.Xresources)-.18 E F2(SEE ALSO)72 638.4 Q F0\n",
      ".901(The v)108 650.4 R .901(arious Ghostscript document \\214les \\(abo)\n",
      "-.25 F -.15(ve)-.15 G .901(\\), especially).15 F F1(Use.htm)3.401 E F0\n",
      "5.901(.O)C 3.401(nD)-5.901 G .9(ebian you may need to install)-3.401 F\n",
      "(ghostscript-doc before reading the documentation.)108 662.4 Q F2 -.11\n",
      "(BU)72 679.2 S(GS).11 E F0(See http://b)108 691.2 Q\n",
      "(ugs.ghostscript.com/ and the Usenet ne)-.2 E\n",
      "(ws group comp.lang.postscript.)-.25 E 188.445(9.27 4)72 768 R\n",
      "(April 2019)2.5 E(5)203.445 E 0 Cg EP\n",
      "%%Page: 6 6\n",
      "%%BeginPageSetup\n",
      "BP\n",
      "%%EndPageSetup\n",
      "/F0 10/Times-Roman@0 SF 184.005(GS\\(1\\) Ghostscript GS\\(1\\))72 48 R/F1\n",
      "10.95/Times-Bold@0 SF(VERSION)72 84 Q F0(This document w)108 96 Q\n",
      "(as last re)-.1 E(vised for Ghostscript v)-.25 E(ersion 9.27.)-.15 E F1\n",
      "-.548(AU)72 112.8 S(THOR).548 E F0(Artife)108 124.8 Q 4.865(xS)-.15 G\n",
      "(oftw)-4.865 E 2.366\n",
      "(are, Inc. are the primary maintainers of Ghostscript.)-.1 F 2.366\n",
      "(Russell J. Lang, gsvie)7.366 F 4.866(wa)-.25 G 4.866(tg)-4.866 G(host-)\n",
      "-4.866 E(gum.com.au, is the author of most of the MS W)108 136.8 Q(indo)\n",
      "-.4 E(ws code in Ghostscript.)-.25 E 188.445(9.27 4)72 768 R(April 2019)\n",
      "2.5 E(6)203.445 E 0 Cg EP\n",
      "%%Trailer\n",
      "end\n",
      "%%EOF\n"
     ]
    }
   ],
   "source": [
    "!man -t gs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First let's make a folder for our manuals"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "!mkdir -p man"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's run man gs and pipe the output to ps2pdf, saving in the file [man/gs.pdf](man/gs.pdf)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "!man -t gs | ps2pdf - man/gs.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## A PDF Toolkit\n",
    "\n",
    "* python: ReportLab (more for *generation* not pre-existing PDF)\n",
    "* [gs](gs.pdf)\n",
    "* [ps2pdf](ps2pdf.pdf), [pdf2ps](pdf2ps.pdf)\n",
    "* [psnup](psnup.pdf), and [poster](poster.pdf)/[pdfposter](pdfposter.pdf)\n",
    "* [pstops](pstops.pdf)\n",
    "* [pdfunite](pdfunite.pdf), [pdfseparate](pdfseparate.pdf)\n",
    "* pdftk\n",
    "* python: [pikepdf](https://github.com/pikepdf/pikepdf) *active project* with [docs](https://pikepdf.readthedocs.io/en/latest/index.html) and a fish logo\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Some links that were used in developing some of this notebook:\n",
    "\n",
    "* https://www.novell.com/documentation/suse91/suselinux-adminguide/html/ch06s08.html\n",
    "* https://wiki.scribus.net/canvas/How_to_make_impositions_with_pstops\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Make some **man**-uals with **ps2pdf**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "!man -t psnup | ps2pdf - man/psnup.pdf\n",
    "!man -t pstops | ps2pdf - man/pstops.pdf\n",
    "!man -t ps2pdf | ps2pdf - man/ps2pdf.pdf\n",
    "!man -t pdf2ps | ps2pdf - man/pdf2ps.pdf\n",
    "!man -t pdftk | ps2pdf - man/pdftk.pdf\n",
    "!man -t pdfposter | ps2pdf - man/pdfposter.pdf\n",
    "!man -t poster | ps2pdf - man/poster.pdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# NB These tools are often part of other packages of tools, for instanced:\n",
    "# apt install ghostscript psutils pdfposter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Read the label with **pdfinfo**\n",
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Title:          \n",
      "Keywords:       \n",
      "Author:         \n",
      "Producer:       cairo 1.16.0 (https://cairographics.org)\n",
      "CreationDate:   Wed Oct 28 19:43:01 2020 CET\n",
      "Tagged:         no\n",
      "UserProperties: no\n",
      "Suspects:       no\n",
      "Form:           none\n",
      "JavaScript:     no\n",
      "Pages:          4\n",
      "Encrypted:      no\n",
      "Page size:      595 x 841 pts\n",
      "Page rot:       0\n",
      "File size:      57323 bytes\n",
      "Optimized:      no\n",
      "PDF version:    1.5\n"
     ]
    }
   ],
   "source": [
    "!pdfinfo txt/language.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Back to the Future with **pdf2ps**\n",
    "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\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pdf2ps txt/language.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[language.ps](language.ps)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## **psnup** saves trees"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] [2] Wrote 2 pages, 481771 bytes\n"
     ]
    }
   ],
   "source": [
    "!psnup -2 language.ps psnup.ps"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To look at it, run the ps2pdf..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DEBUG: FC_WEIGHT didn't match\n"
     ]
    }
   ],
   "source": [
    "!ps2pdf psnup.ps psnup.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "AND LOOK HERE: [psnup.pdf](psnup.pdf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] [2] Wrote 2 pages, 481777 bytes\n"
     ]
    }
   ],
   "source": [
    "!psnup -2 -p a3 -s a3 language.ps psnup.ps"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Repeat the steps above to see it (make sure you close the PDF to reload it).\n",
    "\n",
    "The -c option lays out in column order (instead of rows). Check out the [manual](man/psnup.pdf)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] Wrote 1 pages, 485929 bytes\n"
     ]
    }
   ],
   "source": [
    "!psnup -16 -c language.ps psnup.ps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] Wrote 1 pages, 485997 bytes\n"
     ]
    }
   ],
   "source": [
    "!psnup -16 -c -p a0 language.ps psnup.ps"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## **pdftk** is another PDF toolkit\n",
    "This command can do many things. Let's use it to extract a page"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pdftk A=txt/language.pdf cat A1 output 1.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scale (among other things) with the multi-faceted **pstops**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] [2] [3] [4] Wrote 4 pages, 481656 bytes\n",
      "[1] [2] [3] [4] Wrote 4 pages, 481656 bytes\n"
     ]
    }
   ],
   "source": [
    "!pdf2ps txt/language.pdf 1.ps\n",
    "# Scale up A4 to A2, A0\n",
    "!pstops \"0@2.0\" -pa2 1.ps 1.output.ps\n",
    "!pstops \"0@4.0\" -pa0 1.ps 1.a0.ps"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "NB: When subsequently using **ps2pdf** on a resized postscript file, you should explictly specify the output paper size:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "DEBUG: FC_WEIGHT didn't match\n"
     ]
    }
   ],
   "source": [
    "!ps2pdf -sPAPERSIZE=a0 1.a0.ps 1.a0.pdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Creator:        GPL Ghostscript 927 (ps2write)\n",
      "Producer:       GPL Ghostscript 9.27\n",
      "CreationDate:   Wed Oct 28 21:23:58 2020 CET\n",
      "ModDate:        Wed Oct 28 21:23:58 2020 CET\n",
      "Tagged:         no\n",
      "UserProperties: no\n",
      "Suspects:       no\n",
      "Form:           none\n",
      "JavaScript:     no\n",
      "Pages:          4\n",
      "Encrypted:      no\n",
      "Page size:      2384 x 3370 pts (A0)\n",
      "Page rot:       0\n",
      "File size:      63970 bytes\n",
      "Optimized:      no\n",
      "PDF version:    1.4\n"
     ]
    }
   ],
   "source": [
    "!pdfinfo 1.a0.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## From pdf to ps and back again with a **pipeline sandwich**\n",
    "You might say, what a drag that pstops only scales postscript files and not PDF, well just wrap it in a Pipeline sandwich..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pdf2ps 1.pdf - | pstops \"0@4.0\" -pa2 | ps2pdf -sPAPERSIZE=a0 - 1.a0.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Make a blank PDF with **python** and reportlab.pdfgen.canvas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from reportlab.pdfgen.canvas import Canvas\n",
    "from reportlab.lib.pagesizes import A4\n",
    "c = Canvas(\"blanka4.pdf\", pagesize=A4, bottomup=0)\n",
    "c.showPage()\n",
    "c.save()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Tile and zoom with **poster**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From the [poster](msn/poster.pdf) manual:\n",
    "\n",
    ">*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"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using default whitemargin of 0\n",
      "Deciding for 4 columns and 4 rows of portrait pages.\n",
      "Deciding for a scale factor of 4\n",
      "print page 1\n",
      "DEBUG: FC_WEIGHT didn't match\n",
      "print page 2\n",
      "print page 3\n",
      "print page 4\n",
      "print page 5\n",
      "print page 6\n",
      "print page 7\n",
      "print page 8\n",
      "print page 9\n",
      "print page 10\n",
      "print page 11\n",
      "print page 12\n",
      "print page 13\n",
      "print page 14\n",
      "print page 15\n",
      "print page 16\n",
      "print page 17\n",
      "print page 18\n",
      "print page 19\n",
      "print page 20\n",
      "print page 21\n",
      "print page 22\n",
      "print page 23\n",
      "print page 24\n",
      "print page 25\n",
      "print page 26\n",
      "print page 27\n",
      "print page 28\n",
      "print page 29\n",
      "print page 30\n",
      "print page 31\n",
      "print page 32\n",
      "print page 33\n",
      "print page 34\n",
      "print page 35\n",
      "print page 36\n",
      "print page 37\n",
      "print page 38\n",
      "print page 39\n",
      "print page 40\n",
      "print page 41\n",
      "print page 42\n",
      "print page 43\n",
      "print page 44\n",
      "print page 45\n",
      "print page 46\n",
      "print page 47\n",
      "print page 48\n",
      "print page 49\n",
      "print page 50\n",
      "print page 51\n",
      "print page 52\n",
      "print page 53\n",
      "print page 54\n",
      "print page 55\n",
      "print page 56\n",
      "print page 57\n",
      "print page 58\n",
      "print page 59\n",
      "print page 60\n",
      "print page 61\n",
      "print page 62\n",
      "print page 63\n",
      "print page 64\n"
     ]
    }
   ],
   "source": [
    "#!poster -mA3 -pA0 1.ps | ps2pdf - > poster.poster.pdf\n",
    "!poster -v -c0 -iA4 -mA4 -pA0 1.ps | ps2pdf - > poster.poster.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The newer [pdfposter](man/pdfposter.pdf) works directly with PDF files, and has slightly different options.\n",
    "\n",
    "For example to prints an A4 input file on 8 A3 pages, forming an A0 poster:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pdfposter -mA3 -pA0 1.a0.pdf pdfposter.pdf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## **Puzzle**: Combine tools to make a poster with different elements\n",
    "![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/15-Puzzle.jpg/330px-15-Puzzle.jpg)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
