I have an application where the user can print a document of selected items in the form of an invoice. Everything works well however on the PrintPage event of the PrintDocument I want to capture the document or he graphics, turn it into a bitmap so I can save to it a .bmp for later use / viewing. (Note: There are multiple pages in this document) I have it set up like this:
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
doc.Print();
Then on the PrintPage event:
private void doc_PrintPage(object sender, PrintPageEventArgs ev)
{
// Use ev.Graphics to create the document
// I create the document here
// After I have drawn all the graphics I want to get it and turn it into a bitmap and save it.
}
I have cut out all the ev.Graphics code just because it is a lot of lines. Is there a way to turn the Graphics into a Bitmap without changing any of the code that draws graphics onto the PrintDocument? Or do something similar to that, maybe copying the document and converting it into a bitmap?
You should actually draw the page into the bitmap, and then use ev.Graphics to draw that bitmap on the page.