Introducing ComPDFKit Conversion SDK 1.3.0

By ComPDFKit | 2022 Sep 16
Release Conversion SDK

We are happy to tell you that ComPDFKit Conversion SDK 1.3.0 has been released! A useful feature — converting PDF to images, is supported by our SDK now. We hope the new function will be greatly helpful for our users. Following is a detailed introduction.





JPEG and PNG are the two supported formats when using ComPDFKit Conversion SDK to convert PDF to images. They are the most popular and most confusing image formats. We will compare the much-discussed PNG and JPEG to know how to use each.



JPEG is short for Joint Photographics Export Group. It is a type of image format using the method of lossy compression, which means you will lose some image quality when you convert other formats to JPEG. Sometimes you can see “JPG”, and actually there’s no difference between JPG and JPEG. In the earlier versions of Windows, the file extension had a limit of three letters, which is the reason for the appearance of JPG. The three-letter restriction has gone, and JPEG is now becoming more widely used.


JPEG is designed for minimizing the file size of images to make them more suitable for sharing and using. So the smaller size is the main advantage of JPEG images, which can decrease the loading time and provide better user experience.


Meanwhile, the key advantage of JPEG images is also its disadvantage. The method of compressing JPEG images is to find pixels that are essentially the same color or value, and block them together into tiles. This creates a smaller file, but it also means losing some data in the image, resulting in lower quality. And the data loss is permanent and irreversible, so you can’t restore a JPEG image to its original quality.



PNG means Portable Network Graphics. It is a raster image file format that uses lossless compression. PNG is popular among its users as it doesn’t degrade the image quality.


On the one hand, the lossless compression results in no loss in quality, so the PNG images can be opened, edited, and saved over and over again without degrading. On the other hand, showing transparency is another outstanding advantage of PNG, making it extremely suitable for icons, logos, and smaller graphics that require transparency.


Although PNG images also undergo a different type of image compression, the file size is still larger than JPEG. The loading time will be longer and users may be impatient.


According to the different characteristics of JPEG and PNG, we can know about their respective usage scenarios. JPEG is suitable for real-world photos, like a landscape, a person, or your pet. While PNG is ideal for clear graphics and illustrations, especially when the background needs to be transparent.



Reasons for Converting PDF to Images



As we know, using a PDF processor, like PDF Reader Pro, you can edit PDF files effortlessly. You can add annotations, change content, fill out forms, etc. Although it is convenient, it is not so secure as we may not want the files to be edited by others arbitrarily. Converting an editable PDF document to a fixed image that can’t be easily altered is a solution.


Great compatibility

Since all operating systems have the capability to open image files by default, they are more widely viewable and shareable across many platforms than PDF files. You can’t open a PDF document without PDF software.


Smaller size

As mentioned above, both JPEG and PNG are compressed, so the file size can be partially reduced after converting, which is beneficial for loading and storage.



PDF to Images


When using ComPDFKit Conversion SDK to convert PDF to images, every page of the PDF file will be converted to a separate image, and you can choose the format between JPEG and PNG as you like. All image quality and resolution will remain intact. You can achieve this operation with the following code.



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

CPDFConvertImgOptions *options = [[[CPDFConvertImgOptions alloc] init] autorelease];
[options setType:CPDFConvertImgTypeJPEG];

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



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)



string resPath = "***";
string inputFilePath = "***";
string outputFolderPath = "***";
string outputFileName = "***";

CPDFConverterImg converter = new CPDFConverterImg(inputFilePath);

int pageCount = converter.GetPagesCount();
int[] pageArray = new int[pageCount];
for (int i = 0; i < pageArray.Length; i++)
pageArray[i] = i + 1;

ConvertError error = ConvertError.ERR_UNKNOWN;
converter.Convert(outputFolderPath, ref outputFileName, pageArray,ImgType.JPEG, ref error, getPorgress);



Related Operations


Besides converting PDF to Images, we also support other several format conversions, such as:

- PDF to Word

- PDF to Excel

- PDF to PPT

- PDF to PDF/A

- PDF to TXT

- PDF to CSV

You can visit our documentation to know more about our conversion feature.





Conversion is a practical functionality and we will continue supporting more formats. If you have any suggestions or feedback, please get in touch with us.