title: How to set Paper Size and Margins printing from a web browser control
body: <p>I am trying to print from a web browser control in a winform application.The matter is it sets <strong>letter</strong> as default paper size but I need <strong>A4</strong>. Also it automatically sets some <strong>margins</strong> wrong, I can set them to correct settings manually but I want to do it programmatically.</p>
  
  <p>How is it possible?</p>
  
  <p>Here is my code to print.</p>
  
  <pre><code>private void metroButton1_Click(object sender, EventArgs e)
      {
          loadprintData();
          // Create a WebBrowser instance. 
          WebBrowser webBrowserForPrinting = new WebBrowser();
  
          // Add an event handler that prints the document after it loads.
          wa.DocumentCompleted +=
              new WebBrowserDocumentCompletedEventHandler(ShowPrintDocument);
          wa.ShowPrintPreviewDialog();
          reloadpage();
  
      }
      private void ShowPrintDocument(object sender,WebBrowserDocumentCompletedEventArgs e)
      {
          // Print the document now that it is fully loaded.
          ((WebBrowser)sender).ShowPrintPreviewDialog();
  
          // Dispose the WebBrowser now that the task is complete. 
          // ((WebBrowser)sender).Dispose();
          reloadpage();
      }
      private void PrintDocument(object sender, WebBrowserDocumentCompletedEventArgs e)
      {
          // Print the document now that it is fully loaded.
          ((WebBrowser)sender).Print();
  
          // Dispose the WebBrowser now that the task is complete. 
         // ((WebBrowser)sender).Dispose();
      }
  </code></pre>