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.
- ImageFormat.Bmp
- ImageFormat.Gif
- ImageFormat.Jpeg
- ImageFormat.Png
- ImageFormat.TiffWithCcitGroup3
- ImageFormat.TiffWithCcitGroup4
- ImageFormat.TiffWithLzw
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 class Draw method.
- ceTe.DynamicPDF.Rasterizer.BmpImageFormat
- ceTe.DynamicPDF.Rasterizer.GifImageFormat
- ceTe.DynamicPDF.Rasterizer.JpegImageFormat
- ceTe.DynamicPDF.Rasterizer.PngImageFormat
- ceTe.DynamicPDF.Rasterizer.TiffImageFormat
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)