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

NameTypeAccessDescription
AutoResizeboolRead/WriteGets or sets whether a printed page is scaled to fit the sheet (then multiplied by ScaleFactor).
AutoRotateboolRead/WriteTurn a page whose orientation disagrees with the sheet’s.
AutoRotateModeAutoRotateModeRead/WriteWhich way a page is turned onto a sheet of the other orientation; None leaves it as it is.
CoordinateTypePageCoordinateTypeRead/WriteGets or sets the page box used for printing.
FormPresentationModeFormPresentationModeRead/WriteGets or sets how form fields are presented when printing.
HorizontalAlignmentHorizontalAlignmentRead/WriteGets or sets where a printed page that does not fill the sheet sits horizontally (left, center or right).
VerticalAlignmentVerticalAlignmentRead/WriteGets or sets where a printed page that does not fill the sheet sits vertically (top, center or bottom).
PageCountintReadNumber of pages in the bound document, or 0 when nothing is bound.
PasswordstringRead/WriteOwner password used when opening encrypted documents via OpenPdfFile(string).
PrintAsGrayscaleboolRead/WriteGets or sets whether pages print in gray ink only; such pages are sent to the printer as images.
PrintAsImageboolRead/WriteGets or sets whether each page is sent to the printer as an image rendered at Resolution DPI instead of as drawing commands.
PrintPageDialogboolRead/WriteWhen true, PrintDocumentWithSetup surfaces the OS print dialog.
PrintStatusobjectReadThe failure that ended the last print job, or null when it finished.
PrinterJobNamestringRead/WriteGets or sets the job name shown in the printer queue.
RenderingOptionsAspose.Pdf.RenderingOptionsRead/WriteRendering options applied to every page this viewer rasterises, for DecodePage and for print jobs alike.
ResolutionintRead/WriteTarget rasterisation DPI used by DecodePage / DecodeAllPages.
ScaleFactorfloatRead/WriteGets or sets the scale applied to each printed page; values of 0 or less mean 1.
ShowHiddenAreasboolRead/WriteGets or sets the show hidden areas.
UseIntermidiateImageboolRead/WriteGets or sets the use intermidiate image.

Methods

SignatureDescription
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.

See Also

 English