The PrintDocument Component

The .NET Framework makes use of the System.Drawing. Printing.PrintDocument class for printing output. You can print anything you can draw using the PrintDocument class. Printing in .NET applications is very similar to drawing text and graphics using the classes in the System.Drawing and its child namespaces. You learned about drawing graphical interface elements in Chapter 1, “Introducing Windows Forms.”

To implement printing, you need to create a new instance of the PrintDocument class, set its properties and then call its Print method, which fires the PrintDocument.PrintPage event. You can retrieve a Graphics object from the PrintPage event and treat it as the page from which data can be printed. Using methods of ...

Get Developing and Implementing Windows®-Based Applications with Visual C#™ .NET and Visual Studio® .NET Exam Cram™ 2 (Exam 70-316) 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.