WPF Reflections

Apr 11 2008   2:37PM GMT

Printing with WPF



Posted by: Mark Shurmer
WPF, XAML, printing

How does printing work with WPF?

Well, actually, if anyone out there has ever worked with printing in MFC, then it’s so advanced as to make you dizzy.
Even if you ever tried printing with Windows Forms, then printing in WPF is a bit of a revelation.

So how does it work?

Most of the printing stuff is in the System.Printing namespace, and a good starting place is the PrintDialog class.
By instantiating the PrintDialog class, you can display the standard xp or vista print dialog to allow the user to choose where to print something and how.

What else does it give you?

You can call two different methods to do printing:
PrintVisual - allows you print any class that derives from System.Windows.Media.Visual - which is a lot :-)
PrintDocument - allows you to print any DocumentPaginator, e.g. FlowDocument or XpsDocument.

And it just works :-)

Comment on this Post


You must be logged-in to post a comment. Log-in/Register