Tutorials

Convert a PDF to an Image on Android

By ComPDFKit | Thu. 14 Nov. 2024
AndroidConversion

In the previous blog, we introduced the format JPEG and PNG, along with the reasons why you may need to convert PDF files to images. Today we’ll show you how to convert a PDF to an image on Android and the additional advantages.



Requirements

 

ComPDFKit PDF SDK is supported on Android devices running API level 19 or newer and targeting the latest stable Android version 4.4 or higher. Furthermore, ComPDFKit PDF SDK requires apps to enable Java 8 language features to build.

 

         - Android Studio 3.2 or newer (support AndroidX).

         - Project specifications.

         - A  minSdkVersion of 19 or higher.

         - A compileSdkVersion of 30 or higher.

         - A targetSdkVersion of 30 or higher.

         - Android ABI(s): x86, x86_64, armeabi-v7a, arm64-v8a.

 

For how to run a demo, please refer to the documentation.

 

 

PDF to PNG

 

The demo codes are as below.

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

val params = CPDFConvertImgOptions().apply {
     imgType = ImgType.JPEG
     //imgType = ImgType.PNG
     ...
}

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

 

 

Additional Advantages

 

We described how to set an APP to convert PDF to JPEG, PNG, etc.  Now we’re gonna introduce some additional options we can offer you.

 

DPI 

 

Dots per inch (DPI, or dpi[1]) is a measure of spatial printing, video, or image scanner dot density, in particular the number of individual dots that can be placed in a line within the span of 1 inch (2.54 cm). 

 

For images that DPI needs to be changed, there is one free online tool that may meet your needs: Convert-DPI online.

 

Convert DPI

 

Annotated PDFs

 

If there are important annotations in the PDF file, the annotations will be automatically flattened when converting to an image, so they will not be lost. 

 

This is particularly vital for the company which needs massive annotation, such as Education, Manufacturers, etc.

 

 

ComPDFKit API

 

In addition to ComPDFKit Conversion SDK, our SaaS API can also provide such a service to convert PDFs to PNG, JPEG, or PNG to PDF, etc.

 

ComPDFKit API Tools are easy-to-use APIs that allow you to easily process PDF documents. Fast and easy integration enables you to reduce development and support costs in order to focus all your development time on your core functionality. Your users can instantly modify, and convert PDF documents in your workflows.

 

Sing up here to have a try.



What’s More


There are more capabilities of ComPDFKit Conversion SDK and ComPDFKit API. Such as PDF to Word, PDF to Excel, PDF to PPT, Office to PDF, etc. Please don’t hesitate to contact us if you have any requirements.