Converting pdf file with svg content to image file leads to memory and cpu problems

Hello,

we are using Aspose Pdf for Java (Version 19.10) and it seems that there is a problem with converting pdf file to image file, e.g. png.

Our customer want to convert their pdf documents into png image files. Normally this works really fine .
In given case we do have a 5MB pdf file that contains an svg image (probably the cause of the problem).
Converting to png leads to

  • excessive memory consumption >2GB
  • converting seems to run endlesly (>5h)
  • high CPU performance

(Hint:
Problem occurs after calling convert in RgbToDeviceGrayConversionStrategy
RgbToDeviceGrayConversionStrategy strategy = new RgbToDeviceGrConversionStrategy();

strategy.convert(page);
)

Process of converting is done on our application server and therefore it highly endangers the stability of our application.

  • Is there any possibility to avoid this problem?
    (parameter for RgbToDeviceGrayConversionStrategy or RenderingOptions or others?)
  • Is there any chance to detect problem pdf files before start of conversion, e.g. detect svg content in pdf file? (Missing image file is better than pausing application)
  • Is there any chance to cancel the converting process?

I have added a file to reproduce the problem.
TestAsposePdf2Png.zip (4.5 MB)

Thanks a lot.

Best regards
Matthias

@curmas

Thank you for contacting support.

We have been able to reproduce the issue in our environment and a ticket with ID PDFJAVA-39004 has been logged in our issue management system for further investigations and resolution. Moreover, we are afraid any workaround may not be available yet. We will let you know once any update will be available in this regard.

Furthermore, a feature request to support interrupt monitor based on some time is already logged as PDFJAVA-37532. We will notify you once it will be supported.

Hello Farhan,

are there any possibilities to detect svg image content in a pdf file?
Thanks a lot.

Best regards
Matthias

@curmas

We are afraid image type may not be detected in a PDF document with the API.

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

The issues you have found earlier (filed as PDFJAVA-37532) have been fixed in Aspose.Pdf for Java 24.1.