c# PrintDocument打印空白页.为什么

本文关键字:为什么 空白 打印 PrintDocument | 更新日期: 2023-09-27 18:07:07

我在下面的图片框中填充了条形码,然后尝试打印。

代码如下:

private void button1_Click(object sender, EventArgs e)
{
    printDocument1.OriginAtMargins = true;
    printDocument1.DocumentName = "TEST IMAGE PRINTING";
    printDialog1.Document = printDocument1;
    printDialog1.ShowDialog();
    printDocument1.Print();
}

private void printDocument1_PrintPage_1(object sender, PrintPageEventArgs e)
{
    System.Drawing.Graphics formGraphics = System.Drawing.Graphics.FromImage(picpdf417.Image);
}

c# PrintDocument打印空白页.为什么

您需要实际绘制图像:

private void printDocument1_PrintPage_1(object sender, PrintPageEventArgs e)
{
  e.Graphics.DrawImage(picpdf417.Image, Point.Empty);
}