title: Printing a page without the Print dialog box?
body: <p>I have this ASP.NET page which I would like to print. What I am doing right now is using <code>OnClientClick</code> and from there calling a function <code>PrintThePage()</code> which does nothing but make a call to <code>Window.Print()</code>. When I do this, the user is presented with the Print dialog box, where she can select the printer (and set its properties and what not) and then print the page.</p>
  
  <p>The problem is I want to print the page without showing the print dialog box, using the default printer. Here's what I've tried:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      System.Drawing.Printing.PrinterSettings ps =
          new System.Drawing.Printing.PrinterSettings();
  
      ps.PrintFileName = Path.GetFileName(Request.Url.LocalPath);
  
      System.Drawing.Printing.PrintDocument pd =
          new System.Drawing.Printing.PrintDocument();
  
      pd.PrinterSettings = ps;
      pd.Print();
  }
  </code></pre>
  
  <p>My default printer is <code>OneNote</code> (Microsoft send to One Note). <strong>The problem:</strong> While the page does print, only a blank page is produced.</p>
  
  <p>I first tried to set my default printer to <code>doPdf</code>. When that did not work, I then attempted to use my real HP printer. But I still received the same result. The page isn't showing the print dialog box...that problem is gone. But the problem is why is the page not printing? Why I am getting a blank/null/nada page? Is there a problem in my code? Or is it the fault of my printer? Again, one problem is gone; I am no longer getting the <code>Print Dialog Box</code>. I'm just not getting a printed page, just a blank page.</p>
  
  <p>Can anyone tell me what's happening? What can I do to achieve my goal? (I hope I have made myself clear enough!).</p>