Click or drag to resize
Pdf Library for .NET

PdfRasterizer Class

Converts PDF document pages to images, using the cross-platform native PDF engine.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfTool
    SelectPdf.UniversalPdfRasterizer

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class PdfRasterizer : PdfTool

The PdfRasterizer type exposes the following members.

Constructors
 NameDescription
Public methodPdfRasterizerInitializes a new instance of the PdfRasterizer class.
Top
Properties
 NameDescription
Public propertyColorSpaceThe color space of the generated images. Default RGB.
Public propertyDocumentInformation PDF document information. Populated after the first operation that returns metadata (e.g. GetPageCount, GetInfo).
(Inherited from PdfTool)
Public propertyEndPageNumber The 1-based page number where the current operation ends. The default value is 0, which means the operation runs to the last page.
(Inherited from PdfTool)
Public propertyImagesFormatThe image format for the files written by Save. Default PNG.
Public propertyImagesPathThe folder where Save / SaveTiff write the images.
Public propertyImagesPrefixThe file-name prefix for the images written by Save / SaveTiff.
Public propertyResolutionThe resolution of the generated images in DPI. Default 120.
Public propertyStartPageNumber The 1-based page number where the current operation starts. The default value is 1 (first page).
(Inherited from PdfTool)
Public propertyTimeoutTimeout in seconds for the current operation. Default 600 seconds.
(Inherited from PdfTool)
Public propertyUserPasswordThe user password used to open the PDF document for reading. Default null (no password).
(Inherited from PdfTool)
Top
Methods
 NameDescription
Public methodCode exampleConvertToImages Converts the selected PDF pages to images, each returned as encoded image bytes.
Public methodConvertToTiff Converts the selected PDF pages to a single multi-frame TIFF.
Public methodGetInfoGets the document information (title, author, page count, etc.).
(Inherited from PdfTool)
Public methodGetPageCountGets the number of pages in the loaded PDF document.
(Inherited from PdfTool)
Public methodLoad(Byte)Loads a PDF document from a byte array.
(Inherited from PdfTool)
Public methodLoad(PdfDocument)Loads an in-memory PdfDocument for reading.
(Inherited from PdfTool)
Public methodLoad(Stream)Loads a PDF document from a stream.
(Inherited from PdfTool)
Public methodCode exampleLoad(String)Loads a PDF document from a file.
(Inherited from PdfTool)
Public methodLoad(Byte, String)Loads a password-protected PDF document from a byte array.
(Inherited from PdfTool)
Public methodLoad(PdfDocument, String)Loads an in-memory PdfDocument. The password is used to open the document.
(Inherited from PdfTool)
Public methodLoad(Stream, String)Loads a password-protected PDF document from a stream.
(Inherited from PdfTool)
Public methodLoad(String, String)Loads a password-protected PDF document from a file.
(Inherited from PdfTool)
Public methodCode exampleSave Converts the selected PDF pages to image files written into ImagesPath, named ImagesPrefix + page number, in ImagesFormat.
Public methodSaveTiff Converts the selected PDF pages to a single multi-frame TIFF written into ImagesPath as ImagesPrefix + ".tiff".
Top
Remarks
Load a document with one of the Load overloads (see PdfTool), then call ConvertToImages / ConvertToTiff / Save / SaveTiff. The pages processed are given by StartPageNumber and EndPageNumber.
Example
PdfRasterizer rasterizer = new PdfRasterizer();
rasterizer.Load("document.pdf");
rasterizer.Resolution = 150;
// one PNG per page
byte[][] pngPages = rasterizer.ConvertToImages();
rasterizer.ImagesPath = "output";
rasterizer.ImagesPrefix = "page-";
// writes output/page-1.png, ...
rasterizer.Save();
See Also