Advertisement
Guest User

Untitled

a guest
May 29th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. private void Doc_PrintPage(object sender, PrintPageEventArgs e)
  2. {
  3. float x = e.MarginBounds.Left;
  4. float y = e.MarginBounds.Top;
  5. Bitmap bmp = new Bitmap(this.grbSummarySheet.Width, this.grbSummarySheet.Height);
  6. this.grbSummarySheet.DrawToBitmap(bmp, new Rectangle(0, 0, this.grbSummarySheet.Width, this.grbSummarySheet.Height));
  7. e.Graphics.DrawImage((Image)bmp, x, y);
  8. }
  9.  
  10. private void btnPrint_Click(object sender, EventArgs e)
  11. {
  12. PrintDocument doc = new PrintDocument();
  13. doc.PrintPage += this.Doc_PrintPage;
  14. doc.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("PaperA3", 1200, 1180);
  15. PrintDialog dlgSettings = new PrintDialog();
  16. dlgSettings.Document = doc;
  17. if (dlgSettings.ShowDialog() == DialogResult.OK)
  18. {
  19. doc.Print();
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement