title: How can i set PrintPriviewDialog papersize to a5 in c# codebehind?
body: <p>i have a windows forms application , with a simple windows form that contains a pannel .
  I have set the panel size to :560, 579 in pixels
   and I have set the print document size this way :</p>
  
  <pre><code>System.Drawing.Printing.PaperSize a = new System.Drawing.Printing.PaperSize("A5 (148 x 210 mm)", 584, 827);
  printDocument1.PrinterSettings.DefaultPageSettings.PaperSize = a;
  </code></pre>
  
  <p>now I want the printpreviewdialoge page size to be a5 or at least the same size as my print document and fit it , how can i acheive that ?</p>
  
  <pre><code>    private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
      {
          Bitmap b = new Bitmap(pnlPrint.Width, pnlPrint.Height);
          pnlPrint.DrawToBitmap(b, new System.Drawing.Rectangle(0, 0, pnlPrint.Width, pnlPrint.Height));
          e.Graphics.DrawImage(b,0,0);
      }
  
      private void Print()
      {
      PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
      var paperSize = printDocument1.PrinterSettings.PaperSizes.Cast&lt;PaperSize&gt;().FirstOrDefault(e =&gt; e.PaperName == "A5");
      printDocument1.PrinterSettings.DefaultPageSettings.PaperSize = paperSize; 
      printPreviewDialog1.Document = printDocument1;
  
      printPreviewDialog1.ShowDialog();
  
      }
  </code></pre>