private void printDocument_PrintPage(object sender, PrintPageEventArgs e) { Bitmap image = ImageHandling.GetBitmapFromPanel(mainPanel); Rectangle rect = e.MarginBounds; rect = ImageHandling.GetResizedRectBoundsFromBitmap(image, rect); e.Graphics.DrawImage(image, rect); image.Dispose(); }
private void printDocument_PrintPage(object sender, PrintPageEventArgs e) { Bitmap informationBitmap = ImageHandling.GetBitmapFromPanel(InformationPanel); Rectangle rect = e.MarginBounds; if (personPictureBox.BackgroundImage != Properties.Resources.NoImage) { Bitmap pictureBitmap = (Bitmap)personPictureBox.BackgroundImage; ComposeImage ci = new ComposeImage(new Size(pictureBitmap.Width + informationBitmap.Width, pictureBitmap.Height + informationBitmap.Height)); ci.Images.Add(new ImagePart(new Point(0, 0), pictureBitmap)); ci.Images.Add(new ImagePart(new Point(0, pictureBitmap.Height), informationBitmap)); rect = ImageHandling.GetResizedRectBoundsFromBitmap(ci.ComposeTheImage(), rect); e.Graphics.DrawImage(ci.ComposeTheImage(), rect); } else { rect = ImageHandling.GetResizedRectBoundsFromBitmap(informationBitmap, rect); e.Graphics.DrawImage(informationBitmap, rect); } informationBitmap.Dispose(); }