Skip to main content

Output Image Format

Version: 2.0

Output Image Format

ImageFormat class allows you to define the type of image created by Rasterizer. Several static ImageFormats are defined for quick use. These static members simplify your code significantly when image output types do not need a lot of customization. These static ImageFormats are as follows:

The below example illustrates the syntax that would be needed to rasterize a PDF document into a PNG image using a static PNG ImageFormat.

PdfRasterizer rasterizer = new PdfRasterizer("C:\\DocumentA.pdf");
rasterizer.Draw("C:\\DocumentA_Page.png", ImageFormat.Png, ImageSize.Dpi72);
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer("C:\DocumentA.pdf")
MyRasterizer.Draw("C:\Document_Page.png", ImageFormat.Png, ImageSize.Dpi72)

Alternatively you can just instantiate the ImageFormat type that you need to use and set up it's properties directly. In this case you need to instantiate one of the following objects to pass into the PdfRasterizer's Draw method:

The below example illustrates the syntax that would be needed to rasterize a PDF document into a PNG with transparency. 

PdfRasterizer rasterizer = new PdfRasterizer("C:\\DocumentA.pdf");
PngImageFormat png = new PngImageFormat(PngColorFormat.RgbA);
rasterizer.Draw("C:\\DocumentA_Transparent_Page.png", png, ImageSize.Dpi72);
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer("C:\DocumentA.pdf�)
Dim MyPng As PngImageFormat = New PngImageFormat(PngColorFormat.RgbA)
MyRasterizer.Draw("C:\Document_Transparent_Page.png", MyPng, ImageSize.Dpi72)
Documentation version