title: can I use Ghostscript to overlay a text (fax) header onto a PDF and/or TIFF?
body: <p>I'm writing an application that faxes a document (many supported types) provided by the end user. A requirement is that the end user can also provide text to be used as part of a custom fax header.</p>
  
  <p>I've been using Ghostscript to render PDFs as TIFFs and it's been working great so far, but I have yet to find a straightforward way of overlaying the custom header at the top of a PDF. I've tried out a few recommendations:</p>
  
  <ul>
  <li><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></li>
  <li><a href="https://stackoverflow.com/questions/4766755/how-can-i-add-a-footer-to-the-bottom-of-each-page-of-a-postscript-or-pdf-file-in">How can I add a footer to the bottom of each page of a postscript or pdf file in linux?</a></li>
  <li><a href="https://stackoverflow.com/questions/4427034/add-comments-to-pdf-files-automagically-with-regular-expressions">Add comments to PDF files automagically with regular expressions</a></li>
  <li><a href="https://stackoverflow.com/questions/8470808/stamp-pdf-file-with-control-for-position-stamp-file">Stamp PDF file with control for position of stamp file</a></li>
  </ul>
  
  <p>... with no luck.</p>
  
  <p>I've used ImageMagick to do this successfully with documents rendered to TIFF via other tools, and I'm aware that ImageMagick can render PDF-to-TIFF on its own. However, I want to stick with Ghostscript because in my experience it has performed better and rendered clearer TIFFs.</p>
  
  <p>Is this possible using Ghostscript and perhaps a PS helper script?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Ghostscript (v9.04) is not throwing any errors. For example:</p>
  
  <pre><code>gswin64c -dSAFER -dBATCH -dNOPAUSE -dPDFFitPage -sDEVICE=tiffg3 ^
      -sOutputFile=goofy.tif ^
      -c "/Courier findfont 12 scalefont setfont 50 765 moveto (header text) show" ^
      -f goofy.pdf
  </code></pre>
  
  <p>... produces a TIFF of the original PDF, but without the text I tried to add. If I append <code>showpage</code> to the postscript one-liner it (predictably, I suppose) prints a new, blank-except-for-header page, which doesn't help me much.</p>