1
我有一个PictureBox的列表。以下代码适用于单个PictureBox。无论纸张尺寸如何,我如何在新页面中打印每个PictureBox(或图像)?谢谢 !图像索引的打印清单<PictureBox> - 每页一幅图像
private void btnPrint_Click(object sender, EventArgs e)
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += Doc_PrintPage;
PrintDialog dlgSettings = new PrintDialog();
dlgSettings.Document = doc;
if (dlgSettings.ShowDialog() == DialogResult.OK)
{
doc.Print();
}
}
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
float x = e.MarginBounds.Left;
float y = e.MarginBounds.Top;
Bitmap bmp = new Bitmap(picBox1.Width, picBox1.Height);
//THIS IS OKAY FOR A SINGLE PICTURE BOX.
picBox1.DrawToBitmap(bmp,
new Rectangle(0, 0, picBox1.Width,
picBox1.Height));
e.Graphics.DrawImage((Image)bmp, x, y);
}
+1你是一个明星! – Kaf