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.

The ImageFormat class also has the BmpImageFormat, GifImageFormat, JpegImageFormat, PngImageFormat, and TiffImageFormat child classes that offer formatting options specific to the respective image type.

ImageFormat Properties

The ImageFormat class has the following properties.

AntiAliasing Gets or Sets the AntiAliasing value.
Bmp Gets a default BmpImageFormat class.
DefaultBlackThreshold Gets or sets the default value of black threshold.
DefaultColorPalette Gets or Sets the default color palette.
DefaultDitheringAlgorithm Gets or Sets the default dithering algorithm.
DefaultDitheringPercent Gets or Sets the default dithering percentage.
Gif Gets a default GifImageFormat class.
Jpeg Gets a default JpegImageFormat class.
Png Gets a default PngImageFormat class.
TiffWithCcitGroup3 Gets a default TiffImageFormat class with CCIT Group 3 compression specified.
TiffWithCcitGroup4 Gets a default TiffImageFormat class with CCIT Group 4 compression specified.
TiffWithLzw Gets a default TiffImageFormat class with JPEG compression specified.

ImageFormat Static Types

ImageFormat defines several static image types for quickly specifying the type of image to output. These static members significantly simplify your code when customization is not required.

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

PdfRasterizer rasterizer = new PdfRasterizer("DocumentA.pdf");
rasterizer.Draw("pdf-to-png-output.gif", ImageFormat.Png, ImageSize.Dpi300);
Dim rasterizer As New PdfRasterizer("DocumentA.pdf")
rasterizer.Draw("pdf-to-png-output.gif", ImageFormat.Png, ImageSize.Dpi300)

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 class Draw method.

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

PdfRasterizer rasterizer = new PdfRasterizer("pdf-with-transparency.pdf");
PngImageFormat png = new PngImageFormat(PngColorFormat.RgbA);
rasterizer.Draw("pdf-to-png-transparent-output.png",png, ImageSize.Dpi300);
Dim rasterizer As New PdfRasterizer("pdf-with-transparency.pdf")
Dim png As New PngImageFormat(PngColorFormat.RgbA)
rasterizer.Draw("pdf-to-png-transparent-output.png", png, ImageSize.Dpi300)

In this topic