When we split a document into individual pages of greater than a 1000 and attempt to merge those file back into a single multi page PDF document we get the following Out of Memory exception thrown:
Oct 28, 2019 10:43:06 AM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID ‘junit-jupiter’ failed to execute tests
java.lang.OutOfMemoryError: Java heap space
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.(Throwable.java:88)
at java.lang.Throwable.(Throwable.java:99)
at java.lang.Error.(Error.java:70)
at java.lang.VirtualMachineError.(VirtualMachineError.java:53)
at java.lang.OutOfMemoryError.(OutOfMemoryError.java:58)
at java.lang.String.(String.java:673)
at java.lang.String.(String.java:608)
at com.aspose.pdf.internal.ms.System.l10l.lI(Unknown Source)
at com.aspose.pdf.internal.l8k.l0l.lf(Unknown Source)
at com.aspose.pdf.internal.l9j.lu.lI(Unknown Source)
at com.aspose.pdf.internal.l9j.ld.lI(Unknown Source)
at com.aspose.pdf.internal.l5y.l1l$lI.deserialize(Unknown Source)
at com.aspose.pdf.internal.l9u.le.deserialize(Unknown Source)
at com.aspose.pdf.internal.l5y.l1j$lI.deserialize(Unknown Source)
at com.aspose.pdf.internal.l9u.le.deserialize(Unknown Source)
at com.aspose.pdf.internal.l0k.lh.lI(Unknown Source)
at com.aspose.pdf.internal.l0k.lh.lI(Unknown Source)
at com.aspose.pdf.internal.l0k.lh.lI(Unknown Source)
at com.aspose.pdf.internal.l5y.l1j.l3y(Unknown Source)
at com.aspose.pdf.internal.l5y.l1j.l3v(Unknown Source)
at com.aspose.pdf.internal.l5y.l1j.l5l(Unknown Source)
at com.aspose.pdf.internal.l8k.l0v.lf(Unknown Source)
at com.aspose.pdf.internal.l0n.l0if.lt(Unknown Source)
at com.aspose.pdf.DocumentInfo.(Unknown Source)
at com.aspose.pdf.ADocument.l1p(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.(Unknown Source)
at com.aspose.pdf.Document.(Unknown Source)
at com.aspose.pdf.facades.APdfFileEditor.lI(Unknown Source)
at com.aspose.pdf.facades.APdfFileEditor.concatenate(Unknown Source)
at com.aspose.pdf.facades.PdfFileEditor.concatenate(Unknown Source)
at com.epiq.discovery.pdf.utils.PDFUtils.pdfMergeImageImagePDFBox(PDFUtils.java:68)
at com.epiq.discovery.pdf.utils.PDFUtilsTest.pdfMergeImageImagePDFBox(PDFUtilsTest.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
Below is a snipit of code that we are using to attempt to accomplish this task:
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.setIncrementalUpdates(true);
pdfEditor.setConcatenationPacketSize(100);
pdfEditor.concatenate(singlePageFilePathList.toArray(new String[0]), outputFilePath);
Thanks in advance for any suggestions.