Convert PDF to Image
Overview
ComPDFKit Conversion SDK provides an API for converting PDF to images. Integrate ComPDFKit Conversion SDK to your apps to convert PDF into images easily.
About the picture DPI
The default DPI (Dots Per Inch) for most images is set to 72 DPI. Set the image DPI to 72, ensuring the output matches the PDF's original resolution. To scale the resolution of the output image to certain times, change the DPI 72 to certain times.
Setting Image Formats
In ComPDFKit Conversion SDK, supported image formats include:
- ImageTypeJPG
- ImageTypeJPEG
- ImageTypePNG
- ImageTypeBMP
- ImageTypeTIFF
Setting Image Color Modes
Supported image color modes in ComPDFKit Conversion SDK include:
- ImageColorModeColor: Color mode, where the image effect is consistent with the original PDF page.
- ImageColorModeGray: Grayscale mode.
- ImageColorModeBinary: Black and white mode, which applies binarization to the original effect.
Setting Image Scaling
The SDK supports setting image scaling. The default scaling is 1.0, which maintains the original PDF page size. If you want to double the image size, you can set Scaling
to 2.0; similarly, to reduce the image size by half, set Scaling
to 0.5.
Enhancing Image Path Display
The SDK supports an option called PathEnhance
for enhancing the display of image paths. This option can be enabled when you want to enhance the display effect of paths within the PDF page.
- Not enable
PathEnhance
option(original PDF rendering effect): - Enable
PathEnhance
option:
Notice
- A higher
Scaling
value results in images with higher resolution, but it also increases memory usage and slows down the conversion. - A higher
Scaling
value does not necessarily equate to higher clarity; the clarity also depends on the original image resolution in the document.
Sample
This sample demonstrates how to convert from a PDF to Image file.
ImageOptions *options = [[ImageOptions alloc] init];
options.imageType = ImageTypePNG;
options.imageScaling = 2.0;
[CPDFConversion startPDFToImage:@"input.pdf" password:@"" outputPath:@"output_folder" options:options];