我有一个应用程序,用户可以打印选定项目的文档作为发票。一切都运行良好,但是在PrintDocument
的PrintPage
事件中,我希望捕获文档或图形,将其转换为位图,以便稍后使用/查看时保存为.bmp
。(注意:此文档包含多个页面)我已经按照以下方式设置:
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
doc.Print();
然后在
PrintPage
事件中: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.
}
我已经剪掉了所有的ev.Graphics
代码,因为它有很多行。有没有一种方法可以将Graphics转换成Bitmap而不改变绘制图形到PrintDocument
的任何代码?或者类似于这样做,可能复制文档并将其转换为位图?