Hi Team,
We are facing “Not enough memory to process jpeg file.” exception while converting images(multi-page tiff file) to PDF.
Please find the below complete error.
com.aspose.pdf.internal.ms.System.l8u: FrameworkException: Not enough memory to process jpeg file. at com.aspose.pdf.internal.l60f.lf.(Unknown Source) at com.aspose.pdf.internal.l60f.lf.(Unknown Source) at com.aspose.pdf.internal.l63p.lk.lI(Unknown Source) at com.aspose.pdf.internal.l63p.lj.write(Unknown Source) at javax.imageio.ImageWriter.write(ImageWriter.java:597) at com.aspose.pdf.internal.l58y.lI.lI(Unknown Source) at com.aspose.pdf.internal.l58y.lI.lf(Unknown Source) at com.aspose.pdf.internal.l58y.lI.lf(Unknown Source) at com.aspose.pdf.internal.l58y.lI.lI(Unknown Source) at com.aspose.pdf.internal.l55t.lf.lI(Unknown Source) at com.aspose.pdf.internal.l55t.l1v.lI(Unknown Source) at com.aspose.pdf.internal.l55t.l1v.lI(Unknown Source) at com.aspose.pdf.internal.l55t.l1v.lI(Unknown Source) at com.aspose.pdf.Image.lI(Unknown Source) at com.aspose.pdf.l12if.lI(Unknown Source) at com.aspose.pdf.l12if.le(Unknown Source) at com.aspose.pdf.Page.lf(Unknown Source) at com.aspose.pdf.Page.lc(Unknown Source) at com.aspose.pdf.ADocument.processParagraphs(Unknown Source) at com.aspose.pdf.Document.processParagraphs(Unknown Source) at com.aspose.pdf.ADocument.lf(Unknown Source) at com.aspose.pdf.ADocument.lf(Unknown Source) at com.aspose.pdf.ADocument.save(Unknown Source) at com.aspose.pdf.Document.save(Unknown Source) at com.stormed.common.utils.ImageUtils.imageFileToPdfAspose(ImageUtils.java:256) at com.stormed.common.utils.ImageUtils.imageMergeToPDF(ImageUtils.java:771) at com.stormed.common.utils.ImageUtils.convertImagesToPDF(ImageUtils.java:821) at com.stormed.production.ProductionMain.(ProductionMain.java:87) at com.stormed.production.common.ProductionBuilder.run(ProductionBuilder.java:27) at com.stormed.proxy.AppRunner.run(AppRunner.java:19) at com.stormed.proxy.ProxyMain.runApp(ProxyMain.java:274) at com.stormed.proxy.ProxyMain.lambda$main$0(ProxyMain.java:122) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.OutOfMemoryError: Java heap space
@ashokreddyd Thank you for reaching out to us regarding your concern. We have received your inquiry and would like to assure you that we will thoroughly investigate the matter and come back to you with an answer as soon as possible. Thank you for your patience and understanding.
@ashokreddyd We have tested your file and were unable to open it using either our Aspose.Imaging product or tools such as https://convert.io/, TIFF viewer -- Online Cloud File Viewer, IrfanView, ACDSee. What did you use to open the file and what code did you use to try to load the file?
Please find the steps below and enclosed attachment.
Fetching all the documents to merge using below statement.
for (String imageFilePath : singlePageFilePathListiff_merge_to_pdf.7z (1.4 MB)
t) { // singlePageFilePathList will have documents path list
Reading each image using the statement.
java.awt.image.BufferedImage image = ImageIO.read(new File(inputFilePath));
Create Document object save document to output path
Document pdfDocument = new Document();
com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();
image1.setBufferedImage(image);
page.getParagraphs().add(image1);
Using below statement to merge all the files.
String pdfFilePath = imageFilePath.substring(0, imageFilePath.lastIndexOf(’.’)) + “.pdf”;
List pdfFileList = new ArrayList<>();
pdfFileList.add(pdfFilePath);
new com.aspose.pdf.facades.PdfFileEditor().concatenate(pdfFileList.toArray(new String[0]), outFilePath);
@ashokreddyd Got it. Your request is related to Aspose.PDF, not Aspose.Imaging. Therefore, I have moved this topic to the correct team’s forum section.
Would you please share the complete code snippet for our reference so that we can test the scenario accordingly and address it? Also, please try to use 23.4 version of the API before sharing the code snippet.
I am also continuing this conversation that @ashokreddyd started about this issue. Thanks for the assistance so far. I have followed your suggestion and upgraded our Aspose version to 23.4 and ran the same test with the 1doc10kpages file again. For this particular issue, I am still getting the “Not enough memory to process jpeg file” error when processing JPEG to PDF.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-42791
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
I also wanted to bring your attention to a previous post that was made by my colleagues in 2021 about a memory leak for converting TIFF to PDF. Here is the link:
We’re now using Java 17, Amazon Coretto Edition. There is also a corresponding internal ticket PDFJAVA-40715Would this help in moving towards a solution?
We will link both tickets and consider these both cases related. We have also updated the ticket information accordingly in our issue management system. We will further inform you once we make some progress towards ticket resolution.
Since the ticket was logged recently, it is pending for analysis. We will investigate it on a first come first serve basis and as soon as we have some updates in this regard, we will inform you. Please spare us some time.
We are sorry that the ticket has not been yet resolved due to other issues in the queue. As soon as we make some progress towards ticket resolution, we will let you know in this forum thread. Please be patient and spare us some time.