Display a Dynamic Print Preview

Problem

You want to use an on-screen preview that shows how a printed document will look.

Solution

Use the PrintPreviewControl or PrintPreviewDialog.

Discussion

As described earlier, the code used to print a document to a page is almost identical to the code used to draw graphics on a window. This makes it possible for you to create code that can print or draw a print preview with equal ease. However, you don’t need to go to this extra step because .NET already provides a control that can take a print document, run your printing code, and use it to generate a graphical on-screen preview. In fact, .NET provides two such controls: PrintPreviewDialog, which shows a preview in a standalone window, and PrintPreviewControl ...

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.