private void Doc_PrintPage(object sender, PrintPageEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; e.Graphics.InterpolationMode = InterpolationMode.High; float x = e.MarginBounds.Left; float y = e.MarginBounds.Top; // Panel1 is the name of the panel that the table rest in Bitmap bmp = new Bitmap(this.panel1.Width, this.panel1.Height); this.panel1.DrawToBitmap(bmp, new Rectangle(0, 0, this.panel1.Width, this.panel1.Height)); e.Graphics.DrawImage((Image)bmp, x, y); } private void PrintPreview_Click(object sender, EventArgs e) { PrintDocument doc = new PrintDocument(); doc.PrintPage += this.Doc_PrintPage; Margins margins = new Margins(20, 20, 20, 10); doc.DefaultPageSettings.Margins = margins; printPreviewDialog1.Document = doc; printPreviewDialog1.ShowDialog(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)