title: How to print a PDF with C#
body: <p>I´ve trying to solve this problem for nearly 2 days. There are a lot of more or fewer good solutions on the net, but not a single one fits my task perfectly.</p>
  
  <h2><strong>Task:</strong></h2>
  
  <ul>
  <li>Print a PDF programmatically</li>
  <li>Do it with a fixed printer</li>
  <li>Don´t let the user do more than one Button_Click</li>
  <li>Do it silent - the more, the better</li>
  <li>Do it client side</li>
  </ul>
  
  <h2><strong>First Solutions:</strong></h2>
  
  <p><strong>Do it with a Forms.WebBrowser</strong></p>
  
  <p>If we have Adobe Reader installed, there is a plugin to show PDF´s in the webbrowser. With this solution we have a nice preview and with webbrowserControlName.Print() we can trigger the control to print its content.</p>
  
  <p>Problem - we still have a PrintDialog.</p>
  
  <hr>
  
  <p><strong>Start the AcroRd32.exe with start arguments</strong></p>
  
  <p>The following CMD command let us use Adobe Reader to print our PDF.</p>
  
  <p><em>InsertPathTo..\AcroRd32.exe /t "C:\sample.pdf" "\printerNetwork\printerName"</em></p>
  
  <p>Problems - we need the absolute path to AcroRd32.exe | there is an Adobe Reader Window opening and it has to be opened until the print task is ready. </p>
  
  <hr>
  
  <p><strong>Use windows presets</strong></p>
  
  <pre><code>Process process = new Process();
  
  process.StartInfo.FileName = pathToPdf; 
  process.StartInfo.Verb = "printto";
  process.StartInfo.Arguments = "\"" + printerName + "\""; 
  process.Start();
  
  process.WaitForInputIdle();
  process.Kill();
  </code></pre>
  
  <p>Problem - there is still an Adobe Reader window popping up, but after the printing is done it closes itself usually.</p>
  
  <p>Solution - convince the client to use Foxit Reader (don´t use last two lines of code).</p>
  
  <hr>
  
  <p><strong>Convert PDF pages to Drawing.Image</strong></p>
  
  <p>I´ve no idea how to do it with code, but when I get this to work the rest is just a piece of cake. Printing.PrintDocument can fulfill all demands. </p>
  
  <hr>
  
  <h2><em>Anyone an idea to get some Drawing.Image´s out of those PDF´s or another approach how to do it?</em></h2>
  
  <p>Best Regards,
  Max</p>