title: Programmatically print to PDF using "Microsoft Print to PDF" in c# windows 10
body: <p>I am trying to print to pdf using "Microsoft Print to PDF" in c#. I worked really hard on it and wrote below code.</p>
  
  <p>It is creating an empty pdf file instead of filling it with the content of I sent to the printer.</p>
  
  <p>Could anyone help me?</p>
  
  <pre><code>try
  {
      PrintDocument pd = new PrintDocument();
      ProcessStartInfo info = new ProcessStartInfo("E:\\ba\\Asp.pdf");
      info.Verb = "Print";
      pd.PrinterSettings.PrintToFile = true;
      pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";
      pd.PrinterSettings.PrintToFile = true;
      pd.PrinterSettings.PrintFileName = Path.Combine("e://", "hktespri" + ".pdf");
      pd.Print();
      info.CreateNoWindow = true;
  }
  catch (Exception ex)
  {
      MessageBox.Show(ex.Message);
  
  }
  </code></pre>