Image Ausdrucken

OliWan

Mitglied
Hi Coder,

ich sitze schon seit zwei Tagen an einer echt blöden Sache :-(

Hier ein paar Grundlagen:

Ich habe ein WinForm mit einer PictureBox. Hierein lade
ich ein Image.
Das Image soll per Button-Click ausdruckbar sein.
Das Image ist größer als die PictureBox.

Hier ist ein Code Snippet:

private void button3_Click(object sender, System.EventArgs e)
{
PrintDialog1.AllowSomePages = true;

PrintDialog1.ShowHelp = true;

PrintDialog1.Document = docToPrint;

DialogResult result = PrintDialog1.ShowDialog();

if (result==DialogResult.OK)
{
docToPrint.Print();
}

}

private void document_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{

thisimage = new Bitmap(image); // <- ich lade das Bild hier mal so - geht auch mit this.pictureBox1.Image//

RectangleF srcRect = new Rectangle(0, 0, thisimage.Width, thisimage.Height);

// Create the destination rectangle from the printer settings holding printer page dimensions
int nWidth = docToPrint.PrinterSettings.DefaultPageSettings.PaperSize.Width;
int nHeight = docToPrint.PrinterSettings.DefaultPageSettings.PaperSize.Height;
RectangleF destRect = new Rectangle(0, 0, nWidth, nHeight/2);

// Draw the image scaled to fit on a printed page
e.Graphics.DrawImage(thisimage, destRect, srcRect, GraphicsUnit.Pixel);

}

}

Dummerweise schmeißt mein Drucker nach dem Druckerdialog immer nur ne leere Seite aus?!

Hat da jemand ne Idee?

Gruß OliWan
...may the force be with you
 
Zurück