Print a Document That Has Multiple Pages

Problem

You want 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 set the PrintPageEventArgs.HasMorePages property to True as long as there are pages remaining.

Discussion

The PrintDocument.PrintPage event allows 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 True, the PrintDocument class will continue firing PrintPage events, one for each page. However, it’s up to you to track what page you are on, what data ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook 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.