Output Image Size
DynamicPDF Rasterizer for .NET provides both a static ImageSize class for easily creating images from PDFs and several classes that extend ImageSize that supports creating images with custom sizing.
Static ImageSize
DynamicPDF Rasterizer for .NET provides an ImageSize class which specifies the height, width, horizontal resolution and vertical resolution of a generated image. DynamicPDF Rasterizer defines the following static ImageSize classes for quick use in your applications.
Use an ImageSize subclass with the Draw method, described below, to create custom sized images.
ceTe.DynamicPDF.Rasterizer.ImageSize.Dpi150
- Horizontal DPI (Dots Per Inch): 150
- Vertical DPI: 150
ceTe.DynamicPDF.Rasterizer.ImageSize.Dpi300
- Horizontal DPI: 300
- Vertical DPI: 300
ceTe.DynamicPDF.Rasterizer.ImageSize.Dpi600
- Horizontal DPI: 600
- Vertical DPI: 600
ceTe.DynamicPDF.Rasterizer.ImageSize.Dpi72
- Horizontal DPI: 72
- Vertical DPI: 72
ceTe.DynamicPDF.Rasterizer.ImageSize.Dpi96
- Horizontal DPI: 96
- Vertical DPI: 96
ceTe.DynamicPDF.Rasterizer.ImageSize.FaxStandard
- Horizontal DPI: 204
- Vertical DPI: 98
ceTe.DynamicPDF.Rasterizer.ImageSize.FaxFine
- Horizontal DPI: 204
- Vertical DPI: 196
ceTe.DynamicPDF.Rasterizer.ImageSize.FaxSuperfine
- Horizontal DPI: 200
- Vertical DPI: 400
The following example illustrates rasterizing a PDF document into a JPEG image using a static ImageSize.
PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath);
rasterizer.Draw(pngFilePath, ImageFormat.Jpeg, ImageSize.Dpi150);
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer(pdfFilePath)
MyRasterizer.Draw(pngFilePath, ImageFormat.Jpeg, ImageSize.Dpi150)
ImageSize Using Draw Method
Rather than using a static image size, you can use one of the classes that inherit from the ImageSize class.
- ceTe.DynamicPDF.Rasterizer.DpiImageSize - Allows defining any horizontal and vertical DPI (Dots Per Inch) for an outputted image.
- ceTe.DynamicPDF.Rasterizer.FixedImageSize - Allows defining any height and width for an outputted image.
- ceTe.DynamicPDF.Rasterizer.MaxImageSize - Allows defining any height and width for an outputted image but MaxImageSize only outputs the final image as large as you have defined while still maintaining the original document proportions.
- ceTe.DynamicPDF.Rasterizer.PercentageImageSize - Allows any horizontal or vertical percentage (of the original document) to be defined for the output image.
Pass one of the listed subclasses into the PdfRasterizer class's Draw method to create the custom-sized image. The following example illustrates rasterizing a PDF document into a JPEG that is 200 points in height and 200 points in width.
PdfRasterizer rasterizer = new PdfRasterizer(pdfFilePath);
FixedImageSize jpegSize = new FixedImageSize(200, 200);
rasterizer.Draw(pngFilePath, ImageFormat.Jpeg, jpegSize);
Dim MyRasterizer As PdfRasterizer = New PdfRasterizer(pdfFilePath)
Dim MyJpegSize As FixedImageSize = New FixedImageSize(200, 200)
MyRasterizer.Draw(pngFilePath, ImageFormat.Jpeg, MyJpegSize)