title: Is it possible in Ghostscript to add watermark to every page in PDF
body: <p>I convert <em>PDF -> many JPEG</em> and <em>many JPEG -> many PDF</em> using <code>ghostscript</code>. I need to add watermark text on every converted JPEG (PDF) page. Is it possible using only Ghostscript and PostScript?</p>
  
  <p>The only way I found:</p>
  
  <blockquote>
    <p>gswin32c -q -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile=output.pdf watermark.ps input.pdf</p>
  </blockquote>
  
  <p>But this will insert <code>watermark.ps</code> watermark on first separate page in <code>output.pdf</code>.</p>
  
  <p>Can I do this on output PDF pages directly? </p>
  
  <p>Can I do this on output JPEG pages directly?</p>
  
  <pre><code>&lt;&lt;
     /BeginPage
     { gsave
         /Helvetica_Bold 120 selectfont
         .85 setgray 130 70 moveto 50 rotate (Sample) show
       grestore
     } bind
  &gt;&gt; setpagedevice
  </code></pre>
  
  <p>If I use <code>/EndPage</code> instead of <code>/BeginPage</code> - it says <code>setpagedevice</code> is not applicable...</p>
  
  <p>How to remake this script for <code>/EndPage</code>? </p>