Merge/Concatenate PDF files in Java using Aspose.PDF - OutOfMemoryException occurs with large files

Hi,


I have a question related aspose PDF- concatenating multiple PDF files. I am using concatenate API from library class com.aspose.pdf.kit.PdfFileEditor and works really fine.But when I try to concatenate large PDFs or PDF with large size attachments, like around 4 pdf files with 100mb each, it throws OutOfMemory exception from library functions even thought i increase my JVM size. So, I would like to know is there any maximum limit or cap on sizes it can handle.

Thanks,
Santosh

Hi Santosh,

Thanks for your inquiry. Please note there is no limitation of PDF file size or number of PDF files to concatenate. However, Aspose.Pdf processes the files in memory instead disk, so performance depends upon the file size/contents and system resources.

When concatenating PDF documents using PdfFileEditorr, you can use UseDiskBuffer property. If this property is set to true then resultant document of concatenation is resaved during concatenation. Using of this property makes concatenation with incremental updates. This allows to save memory and somehow increase in performance, because we do not need to store all document data in memory. Number of documents which will be concatenated before next re-save is determined by ConcatenationPacketSize property. Please try following code snippet and share the results, hopefully it will help you to resolve OutOfMemoryException issue.

Furthermore, Please note you are using a quite older version. Since Aspose.Pdf for Java 4.0, we’ve merged Aspose.Pdf for Java and Aspose.Pdf Kit for Java into a single version of Aspose.Pdf for .NET. Aspose.Kit for Java moved under com.aspose.pdf.facades namespace. Please download latest version of Aspose.Pdf for Java and migrate your code to com.aspose.pdf.facades.

PdfFileEditor editor = **new** PdfFileEditor();

editor.setUseDiskBuffer(**true**);

editor.setConcatenationPacketSize(100);

editor.concatenate(fileArray,“C:\data\Merged.pdf”);

Please feel free to contact us for any further assistance.

Best Regards,

Thanks a lot for the quick reply and appreciate your help. Will surely try the above suggestion and see how that works.

Hi Santosh,


Please continue using our API’s and in the event of any further query, please feel free to contact.

I have a quick question, we are trying to decide which product to use for pdf manipulations. Your product is one of them that we consider. I face an issue when I concatenate pdf’s. If a pdf saved that zoomed 125 and another one 150. Concatenation grabs 125 and corps some input from 150 one. Is there any solution for this?

Enging:
I have a quick question, we are trying to decide which product to use for pdf manipulations. Your product is one of them that we consider. I face an issue when I concatenate pdf's. If a pdf saved that zoomed 125 and another one 150. Concatenation grabs 125 and corps some input from 150 one. Is there any solution for this?
Hi,

Thanks for contacting support.

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