PdfViewer
Overview
PdfViewer is a class in Aspose.PDF FOSS for .NET.
Inherits from: IFacade, System.IDisposable.
Façade for viewing and printing a PDF document.
This class declares 36 methods for PdfViewer objects in .NET programs.
Available methods include: BindPdf, Close, ClosePdfFile, DecodeAllPages, DecodePage, DecodePageToImage, Dispose, GetDefaultPageSettings, GetDefaultPrinterSettings, OpenPdfFile, PdfViewer, PrintDocument, and 5 additional methods.
Public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: AutoResize, AutoRotate, AutoRotateMode, CoordinateType, FormPresentationMode, HorizontalAlignment, and 13 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
AutoResize | bool | Read/Write | Gets or sets whether a printed page is scaled to fit the sheet (then multiplied by ScaleFactor). |
AutoRotate | bool | Read/Write | Turn a page whose orientation disagrees with the sheet’s. |
AutoRotateMode | AutoRotateMode | Read/Write | Which way a page is turned onto a sheet of the other orientation; None leaves it as it is. |
CoordinateType | PageCoordinateType | Read/Write | Gets or sets the page box used for printing. |
FormPresentationMode | FormPresentationMode | Read/Write | Gets or sets how form fields are presented when printing. |
HorizontalAlignment | HorizontalAlignment | Read/Write | Gets or sets where a printed page that does not fill the sheet sits horizontally (left, center or right). |
VerticalAlignment | VerticalAlignment | Read/Write | Gets or sets where a printed page that does not fill the sheet sits vertically (top, center or bottom). |
PageCount | int | Read | Number of pages in the bound document, or 0 when nothing is bound. |
Password | string | Read/Write | Owner password used when opening encrypted documents via OpenPdfFile(string). |
PrintAsGrayscale | bool | Read/Write | Gets or sets whether pages print in gray ink only; such pages are sent to the printer as images. |
PrintAsImage | bool | Read/Write | Gets or sets whether each page is sent to the printer as an image rendered at Resolution DPI instead of as drawing commands. |
PrintPageDialog | bool | Read/Write | When true, PrintDocumentWithSetup surfaces the OS print dialog. |
PrintStatus | object | Read | The failure that ended the last print job, or null when it finished. |
PrinterJobName | string | Read/Write | Gets or sets the job name shown in the printer queue. |
RenderingOptions | Aspose.Pdf.RenderingOptions | Read/Write | Rendering options applied to every page this viewer rasterises, for DecodePage and for print jobs alike. |
Resolution | int | Read/Write | Target rasterisation DPI used by DecodePage / DecodeAllPages. |
ScaleFactor | float | Read/Write | Gets or sets the scale applied to each printed page; values of 0 or less mean 1. |
ShowHiddenAreas | bool | Read/Write | Gets or sets the show hidden areas. |
UseIntermidiateImage | bool | Read/Write | Gets or sets the use intermidiate image. |
Methods
| Signature | Description |
|---|---|
PdfViewer() | Creates a viewer with no document bound; call BindPdf before printing or rendering. |
PdfViewer(document: Document) | Creates a viewer bound to an already opened document, which the viewer does not dispose. |
BindPdf(srcDoc: Document) | Binds an already opened document, which the viewer does not dispose. |
BindPdf(srcFile: string) | Opens the PDF file at the given path (using Password when set) and binds it. |
BindPdf(srcStream: Stream) | Reads the whole stream (from the start when it is seekable), opens it using Password when set, and binds it. |
OpenPdfFile(filePath: string) | Calls OpenPdfFile(filePath) on this PdfViewer instance. |
OpenPdfFile(inputStream: Stream) | Calls OpenPdfFile(inputStream) on this PdfViewer instance. |
Close() | Releases the bound document; it is disposed only when the viewer opened it itself. |
ClosePdfFile() | Calls ClosePdfFile on this PdfViewer instance. |
Dispose() | Calls Dispose on this PdfViewer instance. |
Save(destFile: string) | Saves the bound document to the given file path. |
Save(destStream: Stream) | Saves the bound document to the given stream. |
DecodePage(pageNumber: int) | Renders one page (1-based) to a Bitmap at Resolution DPI. |
DecodePageToImage(pageNumber: int, imageFormat: System.Drawing.Imaging.ImageFormat) | Renders one page (1-based) at Resolution DPI and returns it as an image encoded in imageFormat - a PNG by default. |
DecodeAllPages() | Renders every page to a Bitmap; see DecodePage(int). |
GetDefaultPageSettings() | Page settings for a job on the default printer: bound to GetDefaultPrinterSettings and carrying its zero margins, with the paper left to the printer settings. |
GetDefaultPrinterSettings() | Printer settings for a job on the default printer, covering every page of the bound document. |
PrintDocument() | Prints the bound document to the default printer. |
PrintDocumentWithSettings(printerSettings: PrinterSettings) | Prints the bound document with the given printer settings. |
PrintDocumentWithSettings(pageSettings: PageSettings, printerSettings: PrinterSettings) | Prints the bound document with the given page and printer settings. |
PrintDocumentWithSetup() | Prints the bound document with its current settings. |
PrintDocuments(documents) | Prints several documents as one job on the default printer. |
PrintDocuments(filePaths) | Opens the PDF files at the given paths and prints them as one job on the default printer (Windows only). |
PrintDocuments(documentStreams) | Opens the PDF documents in the given streams and prints them as one job on the default printer (Windows only). |
PrintDocuments(printerSettings: PrinterSettings, documents) | Prints several documents as one job with the given printer settings (Windows only). |
PrintDocuments(printerSettings: PrinterSettings, filePaths) | Opens the PDF files at the given paths and prints them as one job with the given printer settings (Windows only). |
PrintDocuments(printerSettings: PrinterSettings, documentStreams) | Opens the PDF documents in the given streams and prints them as one job with the given printer settings (Windows only). |
PrintDocuments(printerSettings: PrinterSettings, pageSettings: PageSettings, documents) | Prints several documents as one job with the given printer and page settings (Windows only). |
PrintDocuments(printerSettings: PrinterSettings, pageSettings: PageSettings, filePaths) | Opens the PDF files at the given paths and prints them as one job with the given printer and page settings (Windows only). |
PrintDocuments(printerSettings: PrinterSettings, pageSettings: PageSettings, documentStreams) | Opens the PDF documents in the given streams and prints them as one job with the given printer and page settings (Windows only). |
PrintLargePdf(filePath: string) | Prints a document the viewer is not bound to. |
PrintLargePdf(inputStream: Stream) | Calls PrintLargePdf(inputStream) on this PdfViewer instance. |
PrintLargePdf(filePath: string, printerSettings: PrinterSettings) | Calls PrintLargePdf(filePath, printerSettings) on this PdfViewer instance. |
PrintLargePdf(inputStream: Stream, printerSettings: PrinterSettings) | Calls PrintLargePdf(inputStream, printerSettings) on this PdfViewer instance. |
PrintLargePdf(filePath: string, pageSettings: PageSettings, printerSettings: PrinterSettings) | Calls PrintLargePdf(filePath, pageSettings, printerSettings) on this PdfViewer instance. |
PrintLargePdf(inputStream: Stream, pageSettings: PageSettings, printerSettings: PrinterSettings) | Calls PrintLargePdf(inputStream, pageSettings, printerSettings) on this PdfViewer instance. |