ImageGear for Silverlight
Using the PrintPreview and PrintPreviewWindow Classes
See Also Send Feedback
ImageGear for Silverlight User Guide > Using ImageGear for Silverlight > Printing Images > Using the PrintPreview and PrintPreviewWindow Classes

Glossary Item Box

PrintPreview is a UI control that allows the end user to select print settings and print the document pages.

The control contains a preview area, a tab control with printing settings, and Print and Close buttons. The settings include: page numbers to print, page layout, margins, header and footer, annotations, and paper size.

The application can create an instance of the control, either using XAML or in the code, initialize its Document property, and optionally, other properties. The application can initialize page printing settings, such as layout, margins, print fields, paper size, and render settings, using the PrintPreview.ImportPageSettings method.

Once the control is visible to the user, and its Document property is initialized, the user can change the printing settings and preview the pages to be printed. After modifying the necessary settings, the user clicks the Print button to print the document. The control handles the printing process automatically.

In order to see the preview, either the application or the user must specify the paper size. The application can do that using PrintPreview.ImportPageSettings. The user can do that in the Paper tab of the control.
The Paper Size and Paper Orientation settings are used for preview only. For printing, the user must set these settings in the printer’s settings dialog. See the Selecting the Paper Size and Orientation section for more details on selecting paper settings.

In order to customize individual pages for printing, handle the PrintPreview.RequestPrint event. Arguments of this event include a reference to a PrintJob object, and a boolean property SkipPrinting. Use the PrintJob object to implement a custom printing process, based on the settings, selected by the user in the control. Set SkipPrinting property to false to skip the automatic printing process.

The PrintPreview control does not hide itself. Instead, when the document has been printed, or when the user has clicked the Close button, the control sends the RequestClose event to the application. The application can then hide or remove the control from the UI, if needed. The IsCloseButtonVisible property defines whether the Close button is visible.

PrintPreviewWindow is a ChildWindow based wrapper for the PrintPreview control, so it can be used as a dialog. It has almost the same API as PrintPreview, except that it does not have analogs of PrintPreview.RequestClose and PrintPreview.IsCloseButtonVisible.

Due to a Silverlight security limitation, if you are using the PrintPreviewWindow and handle the RequestPrint event, you must create a new PrintPreviewWindow object each time you need to preview and print a document. You can use PrintPreviewWindow.ExportPageSettings and PrintPreviewWindow.ImportPageSettings to transfer dialog settings from one instance of PrintPreviewWindow to another.

See Also

©2012. Accusoft Corporation. All Rights Reserved.