Slow performance while converting PDF to JPG in Java using Aspose.PDF for Java 19.5

We experienced the big performance issue after we upgrade aspose-pdf-18.1.jar to aspose-pdf-19.5.jar
The same code as followings and run with attached file, you could see the time spent double in aspose-pdf-19.5.jar. Also test aspose.pdf-20.1.jar , even slower…

import com.aspose.pdf.Document;
import com.aspose.pdf.Page;
import com.aspose.pdf.devices.JpegDevice;
import com.aspose.pdf.devices.Resolution;

Document pdfAsposeDocument = new Document("");
Resolution resolution = new Resolution((int)DPI);
JpegDevice jpegDevice = new JpegDevice(resolution, (int)DPI);

long timeBefore = System.currentTimeMillis();
for (int pageNum = 1; pageNum <= pdfAsposeDocument.getPages().size(); pageNum++) {
Page pageForAsposePdf = pdfAsposeDocument.getPages().get_Item(pageNum);
jpegDevice.process(pageForAsposePdf, “<output *.png file>”);
}
long timeAfter = System.currentTimeMillis();
long timeSpent = timeAfter - timeBefore;

Thanks for help!

Ruhong

@ruhongcai,

Can you please confirm if you are converting DOC file to PDF using Aspose.PDF. Can you please share complete sample code with us. Also you can convert DOCX file to PDF using Aspose.Words as well.

The updated sample code is here:
Before: aspose-pdf-18.1.jar aspose-words-18.2-jdk16.jar
After: aspose-words-19.6.jar , aspose-pdf-19.5.jar/aspose.pdf-20.1.jar

import com.aspose.pdf.Document;
import com.aspose.pdf.Page;
import com.aspose.pdf.devices.JpegDevice;
import com.aspose.pdf.devices.Resolution;
import com.aspose.words.Document;
import com.aspose.words.PdfSaveOptions;

//Convert docx to pdf
final PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setUpdateFields(false);
saveOptions.setEmbedFullFonts(true);
File converted = new File("C://temp.pdf");
String sourcePath = "C://testBigFile.docx");
com.aspose.words.Documentdoc = new com.aspose.words.Document(sourcePath);
    doc.save(converted.getAbsolutePath(), saveOptions);

//convert pdf to image files
com.aspose.pdf.Document  pdfAsposeDocument = new com.aspose.pdf.Document(converted.getAbsolutePath());
Resolution resolution = new Resolution((int)DPI);
JpegDevice jpegDevice = new JpegDevice(resolution, (int)DPI);

long timeBefore = System.currentTimeMillis();
for (int pageNum = 1; pageNum <= pdfAsposeDocument.getPages().size(); pageNum++) {
	Page pageForAsposePdf = pdfAsposeDocument.getPages().get_Item(pageNum);
	jpegDevice.process(pageForAsposePdf, “<output *.png file>”);
}
long timeAfter = System.currentTimeMillis();
long timeSpent = timeAfter - timeBefore;

System.out.println("Time spent :" + timeSpent);

SlowPerformanceFile.zip (1.1 MB)

@ruhongcai,

I have worked with sample code and source file shared by you using Aspose.PDF latest version and this whole process took Time spent :19788. Can you please share your stats with us so that we may further investigate to help you out.

Here is our test result

aspose-pdf-18.1.jar aspose-words-18.2-jdk16.jar Time Spent:204708

aspose-words-19.6.jar , aspose-pdf-19.5.jar/aspose.pdf-20.1.jar Time Spent:504708.

What version you run? Thanks!

@ruhongcai.

Can you please try to use Aspose.PDF latest version 20.1 on your end. I have already shared my result with you which i generated on my end.

Hi,

I tested again today and still got the slow performance for Aspose.PDF latest version 20.1.
Time Spent:428736

Would you please try running my sample code with sample input file in Windows 10 with the followings?
(1)aspose-pdf-18.1.jar aspose-words-18.2-jdk16.jar
(2)aspose-words-19.6.jar , aspose.pdf-20.1.jar

Please compare (1) and (2) result and see the problem.

Thanks!

Ruhong

@ruhongcai,

Can you please try to use Aspose.Words latest version as well. Also please share complete environment details with us.

Hi,
Here are results
(1)aspose-pdf-18.1.jar aspose-words-18.2-jdk16.jar Time Spent:244305
(2)aspose-words-20.1-jdk17.jar , aspose.pdf-20.1.jar - Time spent :535682

Windows 10
Lenovo
ThinkPad T460s Signature Edition
Intel® Core™ i7-6600U @ 2.60GHz 2.81GHz
20.0 GB
64-bit Operating System, x64-based processor

Thanks!

Ruhong

@ruhongcai,

I like to inform that we are investigating this issue in details. Can you please share DPI values which you used on your end.

DPI = 162

Thanks!

@ruhongcai,

Thanks for contacting support.

I have observed your issue and like to inform that I have created investigation ticket with ID PDFJAVA-39125 in our issue tracking system to investigate and resolve this issue as soon possible.

Thanks!

Please help to solve it as soon as possible, this issue has big impact on our product.

Ruhong

@ruhongcai,

We are working on this and will share good news with you soon.

Would like to check the status of this issue which is critical and blocker for us.

Thanks!

Ruhong

@ruhongcai,

Thanks for contacting support.

We like to inform that issue has been added recently in our issue tracking system and in Aspose.PDF forum the issues are selected for investigation on first come first serve basis. Also the first priority for scheduling and resolution is given to paid Enterprise and priority support customers. Then Aspose.PDF normal or free support customers issues are scheduled and resolved on first come and first come serve basis. We will share the further information with you as soon as the issue will be resolved.