- 2 minutes to read
This document describes how to print a document and customize print settings.
You can print the current document using the Print dialog. To invoke it, use one of the following ways:
click the Print command located on the File toolbar button group;
- press CTRL+P;
right-click the document area and select the Print... item in the context menu.
To invoke the Print dialog in code, call one of the PdfViewer.Print overloaded methods that don't require parameters.
In the invoked Print dialog, you can choose the printer and specify the following printing parameters.
Page range selection can include a set of pages such as 2-5. As a result, 2, 3, 4, 5 pages are printed. You can also stipulate the order of pages, so 2-5, 1, 6 will print pages 2-5, then page 1 followed by page 6.
You can also choose the required option: fit to page, actual size or custom page scaling.
Page orientation can be specified as portrait or landscape. Alternatively, you can tell the printing system to auto calculate the orientation. If the scaling option is set to "fit to page" and orientation is set to "auto", the print engine will attempt to set the orientation and scaling to use most of the available paper size.
To print a document, click the Print button in the Print dialog.
To specify the required printer settings before the Print dialog is shown, handle the PdfViewer.PageSetupDialogShowing event.
To print a document without invoking the Print dialog in code, call the corresponding overload of the PdfViewer.Print method and pass the printer settings (represented by the PdfPrinterSettings object) to this method as an argument.
Before printing a document, you can specify whether to show or hide the print status dialog using the PdfViewer.ShowPrintStatusDialog property.
When the document is printing, the PdfViewer.QueryPageSettings and PdfViewer.PrintPage events are raised. You can perform actions when the document is sent to a printer by handling these events. For example, when the PdfViewer.PrintPage event is handled, you can get the current page number using the PdfPrintPageEventArgs.PageNumber property and cancel the printing on a specific page by setting the e.Cancel property to true.