Aspose pdf page to Png image conversion is very slow

Attached sample pdf that took below time(approximately 2 seconds per page) for converting each page to image (png format). This is very critical for our application and I have seen this issue has been reported multiple times since 2008 or so without a resolution that I can search. Please point me in the right direction to get the issue sorted out as soon as possible.


Do you have a way to convert all pages in Pdf to corresponding number of png images in one shot without iterating through?
Do you have any recommendation on how to improve the performance to convert each page below 0.1 second? What is the best timing that Aspose pdf can do with respect to converting to image?

Page:1 took 1.7641447 seconds
Page:2 took 1.2297482 seconds
Page:3 took 1.8152112 seconds
Page:4 took 2.0662391 seconds
Page:5 took 2.0351087 seconds
Page:6 took 2.1108472 seconds
Page:7 took 2.0043022 seconds
Page:8 took 2.1833687 seconds
Page:9 took 1.6524625 seconds
Page:10 took 0.427869 seconds




Code snipped used


var stopWatch = new Stopwatch();
stopWatch.Start();
Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
Aspose.Pdf.Devices.PngDevice device = new Aspose.Pdf.Devices.PngDevice(resolution);
foreach (Page page in pdfDocument.Pages)
{
pageNum++;
using (var msImage = new MemoryStream())
{
device.Process(pdfDocument.Pages[pageNum], msImage);
}
stopWatch.Stop();
Logger.LogInfo(string.Format(“Page:{0} took {1} seconds”, pageNum, stopWatch.Elapsed.TotalSeconds));
stopWatch.Restart();
}

Hello,


I have the exact same problem on Aspose.PDF 11.0.0 for Java, with values similar to yours.

Any leads on how to improve Pdf Page -> PNG conversion performance?

velugula:
Attached sample pdf that took below time(approximately 2 seconds per page) for converting each page to image (png format). This is very critical for our application and I have seen this issue has been reported multiple times since 2008 or so without a resolution that I can search. Please point me in the right direction to get the issue sorted out as soon as possible.

Do you have a way to convert all pages in Pdf to corresponding number of png images in one shot without iterating through?
Do you have any recommendation on how to improve the performance to convert each page below 0.1 second? What is the best timing that Aspose pdf can do with respect to converting to image?

Page:1 took 1.7641447 seconds
Page:2 took 1.2297482 seconds
Page:3 took 1.8152112 seconds
Page:4 took 2.0662391 seconds
Page:5 took 2.0351087 seconds
Page:6 took 2.1108472 seconds
Page:7 took 2.0043022 seconds
Page:8 took 2.1833687 seconds
Page:9 took 1.6524625 seconds
Page:10 took 0.427869 seconds
Hi Hemakumar,

Thanks for sharing the resource file.

I have tested the scenario and I am able to
notice the same performance related problem. For the sake of correction, I have logged this problem
as PDFNEWNET-40126 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

tampix:
I have the exact same problem on Aspose.PDF 11.0.0 for Java, with values similar to yours.

Any leads on how to improve Pdf Page -> PNG conversion performance?
Hi Nicolas,

Thanks for contacting support.

The time taken by API depends upon the structure and complexity of input file and in order to have optimized performance, we need to analyze individual source file. Can you please share the file which you are using so that we can test the scenario in our environment. We are sorry for your inconvenience.

Hi Team, any resolution on this issue? Many people have complained on this similar issue for several years and I am surprised that you have not prioritized this in your development queue.


Please just don’t ignore this as it is very important for us to optimize the image conversion time for rendering the pdf pages as images on mobile devices. Currently we are stuck due to Aspose pdf library not performing as shown in previous log statements.

If I don’t see any action from your side, I will escalate this to our management to see if we should explore other alternatives to Aspose. Please advise.
velugula:
Hi Team, any resolution on this issue? Many people have complained on this similar issue for several years and I am surprised that you have not prioritized this in your development queue.

Please just don't ignore this as it is very important for us to optimize the image conversion time for rendering the pdf pages as images on mobile devices. Currently we are stuck due to Aspose pdf library not performing as shown in previous log statements.

If I don't see any action from your side, I will escalate this to our management to see if we should explore other alternatives to Aspose. Please advise.
Hi Hemakumar,

Thanks for your patience.

From time to time, we have made many improvements regarding PDF to Image conversion process and as shared earlier, the time taken by API depends upon the input file being used. However as we have recently noticed your reported issue, so is still pending for review and is not yet resolved. The team will start investigating the problem as per their schedule and as soon as we have some definite updates regarding its resolution, we will let you know.

Meanwhile I have also shared your concerns with product team and they will surely consider them during the resolution of this problem.

Hi


I find PDFs of scanned content take a lot longer to process than say a PDF created by Aspose from an Email for example.

Given you say it’s related to the complexity do you have any tips on how to reduce the complexity or flags that could be set to ignore aspects of the page processing that might not be relevant if all you are doing is converting it to an image?

Thanks

Simon

For reference I ran a slow file through this site:


http://convert.town/pdf-to-png

It did the whole lot in a matter of seconds and with Aspose it took minutes and this was generating images of approximately the same size as we’re doing in Aspose.

Simon
simon.fairey:
Hi

I find PDFs of scanned content take a lot longer to process than say a PDF created by Aspose from an Email for example.

Given you say it's related to the complexity do you have any tips on how to reduce the complexity or flags that could be set to ignore aspects of the page processing that might not be relevant if all you are doing is converting it to an image?
Hi Simon,

Thanks for contacting support. I am afraid currently we do not offer the feature to reduce PDF complexity or its structure but in order to get optimized performance during PDF to Image conversion, we need to exclusively test the scenario related to each document (which will improve performance for other files with similar structure). Therefore we request you to please share the resource PDF file, so that we can test the scenario in our environment. We apologize for your inconvenience.

@simon.fairey

Thanks for your patience.

We are pleased to inform you that earlier reported issue PDFJAVA-35491, has been resolved in latest version Aspose.Pdf for Java 17.11.

Please try using the latest release version and in case you face any issue, please feel free to contact us.

@asad.ali,

We also faced same issue while converting from pdf to jpeg file . We tried to use aspose 17.11 jar file but same issue. Please help us on the same topic. which jar file is having the solution. Or we are missing anything to include.

Regards,
Ekta

@Ekta_Vegad

Would you kindly use Aspose.PDF for Java 19.7 in your environment as it is latest version with improved performance. In case you still face any issue, please share your sample PDF with sample code snippet. We will test the scenario in our environment and address it accordingly.

Dear @asad.ali ,
I’m using Aspose.PDF for JAVA 19.11 version. I also have the same issue.
I using the https://convert.town/pdf-to-png is very fast.

Here is my sample code snippet.

ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
Document pdfDocument = new Document(filePath);
Resolution resolution = new Resolution(96);
PngDevice pngDevice = new PngDevice(resolution);
pngDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);

Attach my pdf
AsposeSample.pdf (2.5 MB)

Best regards,
Ziv

@ZivWu

We have tested the scenario in our environment and noticed that API took ~60 seconds to convert your PDF into PNG Image(s). Please note that the API follows DOM (Document Object Model) due to which it loads complete document into memory and allocates its structural elements so that any kind of operation can be performed.

Nevertheless, we have logged a performance related ticket as PDFJAVA-40113 in our issue tracking system to further investigate whether this conversion time could be more improved. We will look into its details and keep you posted with the status of ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFJAVA-40113) have been fixed in Aspose.PDF for Java 23.7.

Thank you for the clarification regarding the DOM. The performance improvements in Aspose.PDF for Java 23.7 are marginal.

Since it is hard to improve performance this way does aspose provide a different approach for high performance pdf to png conversion?

@martin.duerig

At the moment, we can offer only DOM and Facades approach to convert PDF into PNG and with every API update, we are focused on improving the API speed and performance. In your particular case, can you please share your sample PDF and the conversion time details that you are observing at your side? We will log an investigation ticket for it and share the ID with you.

The example can be found here https://forum.aspose.com/t/performance-issue-pdf-to-png/263995.

Which mechanism does the online pdf editor PDF Editor | Online and Free | Aspose.PDF use? It seems to be pretty fast.

@martin.duerig

We believe that an issue has already been logged for the situation discussed in the referenced thread. We will surely inform you once some progress is made regarding ticket resolution.

The online free Apps are combination of different Aspose APIs. Also, the server where they are hosted may offer enough memory for such features to execute fast. Nevertheless, your concerns have been recorded and we will surely inform you once we have some updates for you. We sincerely apologize for the inconvenience faced.