I'm newbie in WPF and I'm trying to print student's exam papers using WPF and I'm creating exam papers using
System.Drawing.Graphics and now I want to print them.
But it seems every printable thing in WPF is somehow a control. I have two problems:
- I don't know how can I print something that I've created via
Graphics Like WinForms
PrintDocument (that has it's own problems)
- I don't know how to create my exampaper in WPF like what I did with graphics.
would you help me with any of theses questions?
Best How To :
You can utilize the utilize the PrintDocument class, which is not WPF specific. This class allows you to send output to a printer. The PrintPage event should be handled, where you utilize the PrintPageEventArgs to obtain a Graphics context; which is used to draw the exam to the printer output. This is considered the Winforms way of printing.
WPF has enhanced printing support, provided by the System.Printing namespace. These printing services are used to manage print jobs, and to discover print queues, and configured printers. Printing in WPF is usually performed by generating an XPS document, by utilizing the XpsDocumentWriter class & methods. However, GDI printing is available as well, which is what you'd likely need, because of the use of System.Drawing.Graphics. Refer to the GDI Print Path section, here.