suchislife
suchislife

Reputation: 1

C# PrintDocument prints blank page. Why?

I have the following picture box I populate with a barcode then try to print.

Here's the code:

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

Upvotes: 4

Views: 3629

Answers (1)

LarsTech
LarsTech

Reputation: 81675

You need to actually draw the image:

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

Upvotes: 5

Related Questions