1.6. Printing

The way in which you draw graphics for printing and print previewing is exactly the same as the way you draw on a bitmap, form, picture box, or other screen object. In every case, you obtain a Graphics object and use its methods to create a picture.

The only difference is in how you obtain the Graphics object. When you are drawing on the screen, you use CreateGraphics or the e.Graphics parameter provided by a Paint event handler. Similarly, when you generate a printout or print preview, you use an e.Graphics parameter provided by a PrintDocument object's PrintPage event handler.

1.6.1. Using PrintPage

The PrintDocument class represents a printout. When you print or create a print preview, you use a PrintDocument object created ...

Get C# Graphics Programming 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.