title: Print PDF using GhostScript
body: <p>I am in need of your support on the following issue since its pulling me for a while. We have a small <code>c#</code> utility, which print given <code>PDF</code> using <code>GhostScript</code>. This print as expected but fail to retain the page formatting’s. However, pages are printed as expected when I switch <code>Adobe Acrobat</code> in place of <code>GhostScript</code>. So I presume, I am making some obvious mistake on the GhostScript's command line arguments .</p>
  
  <p><strong>Background</strong></p>
  
  <p>Following is the core c# logic, which print a given PDF file with varying style across each pages. The given PDF file has pages;</p>
  
  <ol>
  <li>with inconsistent font style and colour</li>
  <li>some of the pages have normal font size where others are printed in extra small</li>
  <li>some of the pages has recommended margin but others have very small margin</li>
  <li>some of the pages are in colour and the rest in grey.</li>
  <li>some of the pages are landscape in style where other are portrait</li>
  </ol>
  
  <p>In concise, the PDF which I am trying to print is nothing but a consolidation (joining individual pdfs into one large pdf) of numerous small sized pdf document with varying fonts style, size, margins. </p>
  
  <p><strong>Issue</strong></p>
  
  <p>Following logic use <code>GhostScript(v9.02)</code> to print PDF file. Though the following logic print any given PDF, it fail to retain the page formatting including <em>header, footer, font size, margin, orientation</em> ( my pdf file has pages those both landscape and portrait).</p>
  
  <p>Interestingly, if I use acrobat reader to print the same PDF then it will print as expected along with all page level formatting's.</p>
  
  <p>PDF specimen: <a href="http://sdrv.ms/1grlBLN" rel="nofollow">First section</a>, <a href="http://sdrv.ms/1f99tv4" rel="nofollow">Second section</a></p>
  
  <pre><code>  void PrintDocument()
      {
           var psInfo = new ProcessStartInfo();
                  psInfo.Arguments =
                      String.Format(
                          " -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile=\"\\\\spool\\{0}\" \"{1}\"",
                          GetDefaultPrinter(), @"C:\PDFOutput\test.pdf");
                  psInfo.FileName = @"C:\Program Files\gs\gs9.10\bin\gswin64c.exe";
                  psInfo.UseShellExecute = false;
  
          using (var process= Process.Start(psInfo))
          {
              process.WaitForExit();
          }
      }
  </code></pre>