PrintPreviewControl
Namespace: Wisej.Web.Ext.PrintPreview
Assembly: Wisej.Web.Ext.PrintPreview (4.1.0.0)
Previews the content of a PrintDocument instance.
- C#
- VB.NET
public class PrintPreviewControl : Control
Public Class PrintPreviewControl
Inherits Control
You can use this control independently from the PrintPreviewDialog, as a child of your containers.
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
PrintPreviewControl()
Initializes a new instance of PrintPreviewControl using the default values.
The new instance uses the PDF viewer.
Properties
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 control.
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 control placed on a page:
var document = new PrintDocument();
document.DocumentName = "Invoice";
document.PrintPage += (s, e) =>
{
e.Graphics.DrawString("Invoice #1001", new Font("Arial", 18), Brushes.Black, 100, 100);
e.HasMorePages = false;
};
this.printPreviewControl1.ViewerType = PrintPreviewDialogViewerType.PDF;
this.printPreviewControl1.Document = document;
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.
Methods
Dispose(disposing)
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean |