10.15. Print a Multipage Document

Problem

You need to print complex documents with multiple pages and possibly print several different documents at once.

Solution

Place the information you want to print into a custom class that derives from PrintDocument, and in the PrintPage event handler, set the PrintPageEventArgs.HasMorePages property to True as long as pages are remaining.

How It Works

The PrintDocument.PrintPage event is triggered to let you to print only a single page. If you need to print more pages, you need to set the PrintPageEventArgs.HasMorePages property to True in the PrintPage event handler. As long as HasMorePages is set to True, the PrintDocument class will continue firing PrintPage events. However, it is up to you to track ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach 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.