Skip to content
Guides

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. Supported image formats inlude PNG and JPEG.

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.

Notice

  • The higher the image DPI setting, the greater the resolution of the produced image. However, this also means that it will consume more memory during processing and will slow down the operation.
  • A higher DPI setting does not necessarily equate to a higher clarity in the image. The sharpness of the image also depends on the resolution of the original document's image.

Sample

This sample demonstrates how to convert from a PDF to Image file.

objective-c
// Get the path of the PDF file.
NSString *pdfPath = @"...";
// Get the path to the ZIP file.
NSString *outputPath = @"...";

CPDFConvertImgOptions *options = [[CPDFConvertImgOptions alloc] init];
[options setType:CPDFConvertImgTypeJPEG];
// Image DPI.
[imgOptions setImageDpi:200];

CPDFConverterImg *converter = [[CPDFConverterImg alloc] initWithURL:[NSURL fileURLWithPath:pdfPath] password:nil];
[converter convertToFilePath:outputPath pageIndexs:nil options:options];