I'm going to display part of my C # WinForms application using PrintDocument , it's almost done, but the problem is with my printers. I use the following codes to capture an image of my form, and then print this image, and finally I use PrintPreviewDialog to display the preview:
PrintDocument doc = new PrintDocument(); doc.PrintPage += doc_PrintPage; doc.Print(); printPreviewDialog1.Document = doc; printPreviewDialog1.ShowDialog();
and this is the doc_PrintPage function:
Bitmap bmp = new Bitmap(tabControl1.Width, tabControl1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); tabControl1.DrawToBitmap(bmp, new Rectangle(0, 0, tabControl1.Width, tabControl1.Height)); e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; e.Graphics.DrawImage((Image)bmp, 0, 0);
When the doc.print() function is doc.print() , the Microsoft OneNote program opens and displays my printable form, and the PrintPreviewDialog control opens a new form containing my preview.
I will have quiet printing, so that no printer program (for example, OneNote installed as my default printer) or a physical printer opens (I think that if my user is connected to a physical printer, the page will actually print, which is definitely not what I want). I just want to display a print preview without any printing, can I print to XPS in any way (virtual printer file?), Or in any other way that doesn't actually work?
source share