title: Print to PDF with Microsoft Print to PDF printer
body: <p>I try to print a ms project file to pdf without any additional action needed.</p>
  
  <p>I have tried several solutions without success.</p>
  
  <pre><code>PrintDocument doc = new PrintDocument()
  {
  //DocumentName = safeDir + fileName,
      PrinterSettings = new PrinterSettings()
      {
          // set the printer to 'Microsoft Print to PDF'
          PrinterName = "Microsoft Print to PDF",
  
          // tell the object this document will print to file
          PrintToFile = true,
  
  
          // set the filename to whatever you like (full path)
          PrintFileName = safeDir + fileName,
      }
  };
  doc.Print();
  </code></pre>
  
  <p>If i try this approach like showed <a href="https://stackoverflow.com/questions/31896952/how-to-programmatically-print-to-pdf-file-without-prompting-for-filename-in-c-sh">here</a>, I get an empty pdf file.</p>
  
  <p>Manually printing to PDF works fine.</p>
  
  <p>Any suggestions to solve this problem?</p>