Output Image Format

The ImageFormat class allows you to define the type of image created by the DynamicPDF Rasterizer. The easiest way to specify an image format is by using one of the ImageFormat class's static types. Alternatively, you can also instantiate an ImageFormat and set the properties directly.

ImageFormat Static Types

ImageFormat defines several static image types for quick use. These static members significantly simplify your code when image output type customization is not required.

The following example illustrates rasterizing a PDF document into a PNG image using a static PNG ImageFormat.

PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath);
rasterizer.Draw(pngFilePath, ImageFormat.Png, ImageSize.Dpi72);        
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer(pdfFilePath)
MyRasterizer.Draw(pngFilePath, ImageFormat.Png, ImageSize.Dpi72)    

Setting ImageFormat Properties

You can also instantiate the ImageFormat type needed and set its properties directly by instantiating one of the following classes and passing it into the PdfRasterizer's Draw method.

The following example illustrates rasterizing a PDF document into a PNG that includes transparency. 

PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath);
PngImageFormat png = new PngImageFormat(PngColorFormat.RgbA);
rasterizer.Draw(pngFilePath, png, ImageSize.Dpi72);        
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer(pdfFilePath)
Dim MyPng As PngImageFormat = New PngImageFormat(PngColorFormat.RgbA)
MyRasterizer.Draw(pngFilePath, MyPng, ImageSize.Dpi72)

In this topic