I have the following code for printing from a panel
public void PrepareImage()
Graphics graphic = panel2.CreateGraphics();
Size s = panel2.Size;
memImage = new Bitmap(s.Width, s.Height, graphic);
Graphics memGraphic = Graphics.FromImage(memImage);
IntPtr dc1 = graphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt(dc2, 0, 0, panel2.ClientRectangle.Width,
panel2.ClientRectangle.Height, dc1, 0, 0, SRCCOPY);
graphic.ReleaseHdc(dc1);
memGraphic.ReleaseHdc(dc2);
}
private void btnprint_Click(object sender, EventArgs e)
{
PrepareImage();
printDocument1.Print();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bmp=new Bitmap(panel2.Width, panel2.Height);
panel2.DrawToBitmap(bmp, new Rectangle(0, 0, panel2.Width, panel2.Height));
e.Graphics.DrawImage(bmp, 0, 0);
}
But it does n't print the entire panel (entire width is not coming).
Actually the panel exceeds the width of the form . I want the contents to be resized to fit in one page.