title: Printing an HTML document
body: <p>I'm printing an HTML document successfully with the following code:</p>
  
  <pre><code>using (WebBrowser webBrowser = new WebBrowser())
  {
      webBrowser.DocumentText = text;
      while (webBrowser.ReadyState != WebBrowserReadyState.Complete)
          Application.DoEvents();
  
      InternetExplorer internetExplorer = (InternetExplorer)webBrowser.ActiveXInstance;
      internetExplorer.PrintTemplateTeardown += InternetExplorer_PrintTemplateTeardown;
      internetExplorer.ExecWB(OLECMDID.OLECMDID_PRINT, OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER);
  
      while (!documentPrinted)
          Application.DoEvents();
  
      internetExplorer.PrintTemplateTeardown -= InternetExplorer_PrintTemplateTeardown;
  }
  </code></pre>
  
  <p>Two problems:  </p>
  
  <ol>
  <li>The printed paper has an header (<code>page 1 of 1</code>) and a footer (<code>about:blank</code> and <code>date</code>). How can I print without them?</li>
  <li>The printed paper is much longer than the actual HTML page content. How can I stop the printing when the content ends?</li>
  </ol>