Chapter 16 Printing
What’s in This Chapter
- Windows Forms printing
- Print previews
- GDI+ drawing basics
- Printing a booklet
- WPF printing with paginators,
FlowDocument
s, andFixedDocument
s
Wrox.com Downloads for This Chapter
Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at www.wrox.com/go/csharp5programmersref on the Download Code tab.
Windows Forms and WPF applications take two different approaches to printing. In a Windows Forms application, the program starts the printing process, and then a document object raises events to ask the program what it should draw on each printed page. A WPF application builds a document object that contains other objects representing printed items, such as text, images, and shapes.
The first part of this chapter describes printing in Windows Forms applications. The second part explains how to generate and print documents in WPF applications.
Windows Forms Printing
Although Windows Forms applications have some good printing tools, the basic process seems somewhat backward for many programmers. Instead of executing commands to tell a printer object what to print, the program must respond to events when a document object asks what it should print.
When you master the basic concepts, printing is mostly a matter of learning how to draw graphics. Drawing graphics in a Windows Forms application is practically the same whether you’re drawing on a form, PictureBox
, or ...
Get C# 5.0 Programmer's Reference 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.