Skip to content
Guides

Convert PDF to Image

Overview

ComPDFKit Conversion SDK provides an API for converting PDFs 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.

Note

  • 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 files.

kotlin
val cPDFConvert = CPDFConverterImg(context, uri, "")

val params = CPDFConvertImgOptions().apply {
     imageDpi = 900
     imgType = ImgType.JPEG
     isContainAnnotations = true
}

val result: ConvertError = cPDFConvert.convert(outputDir, outputFilenameNoSuffix, params, pageArrays, 
onHandle = onHandleCal, 
onProgress = onProgressCal, 
onPost = onPostCal)