Using the PrintDocument Component

Implement print capability.

Printing in the .NET Framework is managed by the PrintDocument class. Typically, you create a new instance of the PrintDocument class, set its properties, and call its Print() method. Calling the method causes the PrintDocument.PrintPage event to occur. You determine what will be printed by adding a handler for this event. In the PrintPage event, you can retrieve and manipulate a Graphics object that lets you treat the next page to be printed as a canvas to draw on. By using the methods of the Graphics class, as well as associated objects (such as the Font or Brush objects), you can determine what to print.

The following sections explain how you can use this printing scheme to print ...

Get MCAD/MCSD.NET Training Guide (Exam 70-316): Developing and Implementing Windows®-Based Applications with Microsoft® Visual C#™ .NET and Microsoft® Visual Studio® .NET 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.