Aspose pdf page to Png image conversion is very slow

Hi Team,


Aspose pdf 9.7.0
Also please let me know what support options do I have or I should continue to use these forums.

In reference to Convert PDF to Different Image Formats in C#|Aspose.PDF for .NET I am converting Pdf document pages --page by page into Png image format using the code in the above linke. PngDevice.Process method is taking 2-3 seconds per each page. So for a Pdf document with 10 pages, it is going to take upto 30 seconds to load on the client side.

Is there any way to improve conversion time? Is there any way to convert all pages in single shot?

My use case is around showing pdf page wise images on mobile devices and we have chosen png/jpeg format.

I have seen similar issues reported by other users and I did not find this issue as resolved. Can you please confirm if the performance of converting pdf to image has been improved or not. It is very critical for our users.

20160107-05.14.40.3747 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 1:71.9234087
20160107-05.14.51.8498 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 3:11.4729171
20160107-05.14.54.3521 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 4:2.5014554
20160107-05.14.56.9313 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 5:2.5791532
20160107-05.14.59.6406 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 6:2.7084775
20160107-05.15.02.4859 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 7:2.8439442
20160107-05.15.05.1142 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 8:2.6275478
20160107-05.15.06.9893 ::HemakumarV :: INFO :: Elapsed time(seconds) for converting page to png image for Aspose document page - 9:1.8745261

Hi Hemakumar,


Thanks for contacting support.

Can you please share your source PDF file, so that we can test the scenario in our environment. We are sorry for this inconvenience.

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.