title: Setting PrinterSettings while printing in c#
body: <p>A few days ago I tried to print a photo from right clicking on the photo. One dialogue box showed up to select Printer, PaperSize, Quality etc. I select <code>PaperSize = Legal</code>.  The printer could print on Legal size paper (I am using HP LaserJet 1020 plus Printer).</p>
  
  <p>Now I am trying to print something from C#, setting PaperSize, but printer is not able to print Legal. Below is my code. Does anything about code wrong?</p>
  
  <pre><code>this.printDocument.PrinterSettings.PrinterName = this.printSetting.PrinterName;
  PaperSize pkCustomSize1 = new PaperSize("8.5x13", 1300, 850);
  this.printDocument.DefaultPageSettings.PaperSize = pkCustomSize1;
  this.printDocument.DefaultPageSettings.PaperSize.RawKind = 119;
  printPreviewDialog.Document = printDocument;
  printDocument.Print();
  
  private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
  {
      Graphics g = e.Graphics;
      Bitmap bm = new Bitmap(300, 3000);
      // Code for bm.
      g.DrawImage(bm, 0, 0);
  }
  </code></pre>
  
  <p>So the question is, what is the proper method to set PaperSize (and PrinterSetting)?
  One more thing, I searched for <code>MaximumPrintableArea</code> of a printer. My printer has maximum A4 size, why it does print on <code>Legal</code>?</p>
  
  <p><img src="https://i.stack.imgur.com/w8ofg.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/yvNIS.jpg" alt="enter image description here"></p>