C#PrintDocument打印空白页面。为什么?

时间:2013-04-01 15:52:06

标签: c#

我有以下图片框,我用条形码填充然后尝试打印。

以下是代码:

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);
}

1 个答案:

答案 0 :(得分:4)

您需要实际绘制图像:

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