title: How can I add a footer to the bottom of each page of a postscript or pdf file in linux?
body: <p>So I'd like to add a "footer" (an attribution) to the bottom of every page of a pdf file I am generating via postscript with groff in linux. I am converting the file from ps to pdf myself, with the ps2pdf tool, so I have access to both formats.</p>
  
  <p>These two posts have been somewhat helpful:</p>
  
  <p><a href="https://stackoverflow.com/questions/1603301/how-to-add-page-numbers-to-postscript-pdf">How to add page numbers to Postscript/PDF</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3689834/how-can-i-make-a-program-overlay-text-on-a-postscript-file">How can I make a program overlay text on a postscript file?</a></p>
  
  <p>I'm not against using the first method, but I don't have access to the <code>pdflatex</code> utility mentioned in the first script, nor do I have the option to install it on the machine that needs to do the work.</p>
  
  <p>It looks like the second method could possibly work, but I have version 8.15 of ghostscript installed and I didn't see many of the flags listed on the man page ( <a href="http://unix.browserdebug.com/man/gs/" rel="nofollow noreferrer">http://unix.browserdebug.com/man/gs/</a> ). I think I have access to the "-c" flag to insert some postscript code, even though it is not listed. Anyhow, here are two commands I tried unsuccessfully:</p>
  
  <pre>
  gs -o output.pdf -sDEVICE=pdfwrite -g5030x5320 \
  -c "/Helvetica-Italic findfont 15 scalefont setfont 453 482 moveto (test-string) show" \
  -f input.ps
  </pre> 
  
  <p>that gives me this:</p>
  
  <pre>
  Unknown switch -o - ignoring
  ESP Ghostscript 815.02 (2006-04-19)
  Copyright (C) 2004 artofcode LLC, Benicia, CA.  All rights reserved.
  This software comes with NO WARRANTY: see the file PUBLIC for details.
  ERROR: /undefinedfilename in (output.pdf)
  Operand stack:
  
  Execution stack:
     %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push
  Dictionary stack:
     --dict:1117/1686(ro)(G)--   --dict:0/20(G)--   --dict:102/200(L)--
  Current allocation mode is local
  Last OS error: 2
  ESP Ghostscript 815.02: Unrecoverable error, exit code 1
  </pre>
  
  <p>So obviously the -o flag has a problem and so I did some research and tried this syntax:</p>
  
  <pre>
  
  gs -sOUTPUTFILE=output.pdf -sDEVICE=pdfwrite -g5030x5320 \
  -c "/Helvetica-Italic findfont 15 scalefont setfont 453 482 moveto (test-string) show" \
  -f input.ps
  
  </pre>
  
  <p>which outputs this and makes me hit return 4 times (maybe there are 4 pages in input.ps)</p>
  
  <pre>
  
  ESP Ghostscript 815.02 (2006-04-19)
  Copyright (C) 2004 artofcode LLC, Benicia, CA.  All rights reserved.
  This software comes with NO WARRANTY: see the file PUBLIC for details.
  Can't find (or can't open) font file /usr/share/ghostscript/8.15/Resource/Font/Helvetica-Italic.
  Can't find (or can't open) font file Helvetica-Italic.
  Querying operating system for font files...
  Didn't find this font on the system!
  Substituting font Helvetica-Oblique for Helvetica-Italic.
  Loading NimbusSanL-ReguItal font from /usr/share/fonts/default/Type1/n019023l.pfb... 3742416 2168114 2083056 759694 1 done.
  Loading NimbusRomNo9L-ReguItal font from /usr/share/fonts/default/Type1/n021023l.pfb... 3781760 2362033 2365632 1015713 1 done.
  Loading NimbusRomNo9L-Medi font from /usr/share/fonts/default/Type1/n021004l.pfb... 3865136 2547267 2365632 1029818 1 done.
  Loading NimbusRomNo9L-Regu font from /usr/share/fonts/default/Type1/n021003l.pfb... 4089592 2759001 2365632 1032885 1 done.
  Using NimbusRomanNo9L-Regu font for NimbusRomNo9L-Regu.
  &gt;&gt;showpage, press &lt;return&gt; to continue&lt;&lt;
  
  &gt;&gt;showpage, press &lt;return&gt; to continue&lt;&lt;
  
  &gt;&gt;showpage, press &lt;return&gt; to continue&lt;&lt;
  
  &gt;&gt;showpage, press &lt;return&gt; to continue&lt;&lt;
  
  
  </pre>
  
  <p>So it seems like it would be simple enough to use <code>gs</code> to simply insert something in a ps file, but it is proving to be quite complicated...</p>