Click here to Skip to main content
15,614,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
printing a panel data I am facing two issues.
1. unable to print on more than one page.
2. the print data is distorted for large content(maximum textboxes and buttons).

What I have tried:

var grd = panel1;
                Bitmap bmp = new Bitmap(grd.Width, 500 * xme, grd.CreateGraphics());
                grd.DrawToBitmap(bmp, new Rectangle(0, 0, grd.Width, grd.Height));
                RectangleF bounds = e.PageSettings.PrintableArea;
                float factor = ((float)bmp.Height / (float)bmp.Width);
                e.Graphics.DrawImage(bmp, bounds.Left, bounds.Top, bounds.Width, factor * bounds.Width);
Updated 27-Dec-20 21:18pm

Use .PrintVisual, referencing the panels.

Printing in WPF[^]
Share this answer
@gerry not working in window form.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900