开发者

C# printer prints just a quarter of the submitted picture

Greetings,

i have a little application which should be able to print single jpeg files to a network printer. Now the printing itself works but the problem is that the printer prints just the upper left quarter of the picture, no matter which picture i use. Typically the picture is 1800x1200 px and in jpeg format.

The code im using to print is the following:

protected void Button5_Click(object sender, EventArgs e)
{
    PrintDocument doc = new PrintDocument();
    doc.PrinterSettings.PrinterName = "KONICA MINOLTA C250/C250P PCL";
    doc.PrintPage += this.Doc_PrintPage;
    if(doc.PrinterSettings.IsValid)
        doc.Print();
}


private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
    float x = e.MarginBounds.Left;
    float y = e.MarginBounds.Top;

    e.Graphics.DrawImage((System.Drawing.Image)ShowIm开发者_Go百科g(bild.ToolTip),x, y);
}

The ShowImg() function just returns a Bitmap with the picture from a network drive. Does anyone know why this strange behaviour happens?

Thanks in advance xen


What are MarginBounds.Height/Width? Take a look at image dimensions too...

private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
    float x = e.MarginBounds.Left;
    float y = e.MarginBounds.Top;
    var img = (System.Drawing.Image)ShowImg(bild.ToolTip);

    Debug.Print("img: {0}x{1}", img.Width, img.Height);    
    Debug.Print("margins: {0}x{1}", e.MarginBounds.Width, e.MarginBounds.Height);    

    e.Graphics.DrawImage(img,x, y);
}

I hope you'll see the difference between their dimensions.


Found out that i was using 300dpi for my jpeg where the printer just supported 90dpi. Silly me :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜