Skip to main content

PrintPreviewDialog

Namespace: Wisej.Web.Ext.PrintPreview

Assembly: Wisej.Web.Ext.PrintPreview (4.1.0.0)

Represents a dialog box form that contains a PrintPreviewControl for printing from a Wisej application using a PrintDocument instance.

public class PrintPreviewDialog : Form

Supports two preview modes: PDF and WMF. When using the PDF mode, it prints the document to a temporary PDF file using the "Microsoft Print to PDF" printer driver installed on the server and displays it in the embedded PDF.js viewer. When using the WMF mode, it uses the PreviewPrintController to print to Windows Meta Files (WMF) images and renders them in the browser.

Constructors​

Instance member PrintPreviewDialog()​

Initializes a new instance of PrintPreviewDialog.

The new instance uses the PDF viewer.

Properties​

Instance member Document​

PrintDocument: Returns or sets the PrintDocument to preview.

The document is printed when the preview is displayed: in PDF mode its PrintController and PrinterSettings are changed to print to a temporary PDF file, in WMF mode its PrintController is replaced with a PreviewPrintController. Set the ViewerType and the document before the preview is displayed.

The document is disposed together with the dialog.

Throws:

  • InvalidPrinterException The printer driver "Microsoft Print to PDF" is not installed on the server. The check is performed when a non-null document is assigned, regardless of the ViewerType.

Example:

Previewing a document in a modal dialog:

private void buttonPreview_Click(object sender, EventArgs e)
{
var document = new PrintDocument();
document.DocumentName = "Report";
document.PrintPage += this.Report_PrintPage;

using (var dialog = new PrintPreviewDialog())
{
dialog.ViewerType = PrintPreviewDialogViewerType.WMF;
dialog.Document = document;
dialog.ShowDialog();
}
}

Instance member ViewerType​

PrintPreviewDialogViewerType: Returns or sets the type of viewer to use to display the print preview. (Default: PDF)

PDF requires the "Microsoft Print to PDF" printer driver on the server. WMF renders each page as an image on the server and displays the pages in a scrollable panel.

Implements​