Basic Printing

Although WPF includes dozens of print-related classes (most of which are found in the System.Printing namespace), there's a single starting point that makes life easy: the PrintDialog class.

The PrintDialog wraps the familiar Print dialog box that lets the user choose the printer and a few other standard print options, such as the number of copies (Figure 20-1). However, the PrintDialog class is more than just a pretty window—it also has the built-in ability to trigger a printout.

To submit a print job with the PrintDialog class, you need to use one of two methods:

  • PrintVisual() works with any class that derives from System.Windows.Media.Visual. This includes any graphic you draw by hand and any element you place in a window. ...

Get Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.