Hi, we are evaluating your Aspose.PDF java library. We need to convert some pdf documents into PDF/A-2b. These documents are large (between 400 and 600 pages). Trying this code:
File filePathContract = new File(filePath);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(FileUtils.readFileToByteArray(filePathContract));
byte[] fileContentByteArray = IOUtils.toByteArray(byteArrayInputStream);
ByteArrayOutputStream pdfAOS = new ByteArrayOutputStream();
if (Document.isLicensed()) {
ByteArrayInputStream pdfAIS = new ByteArrayInputStream(fileContentByteArray);
com.aspose.pdf.Document pdfADocument = new com.aspose.pdf.Document(pdfAIS);
pdfADocument.convert("./1234_conversionLog.xml", PdfFormat.PDF_A_2B, ConvertErrorAction.Delete);
pdfADocument.save(pdfAOS);
pdfADocument.close();
}
with 1.5 GB of maximum heap size (we would not want to increase this value) we get an OutOfMemoryException:
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at com.aspose.pdf.internal.l20k.l29t.(Unknown Source)
at com.aspose.pdf.internal.l20k.l29t.lI(Unknown Source)
at com.aspose.pdf.internal.l6p.ld.l0j(Unknown Source)
at com.aspose.pdf.internal.l6p.lh.lI(Unknown Source)
at com.aspose.pdf.internal.l6p.lh.(Unknown Source)
at com.aspose.pdf.internal.l6p.l0t.lI(Unknown Source)
at com.aspose.pdf.internal.l6p.l0t.lI(Unknown Source)
at com.aspose.pdf.internal.l10t.ly.lI(Unknown Source)
at com.aspose.pdf.internal.l10t.ly.lI(Unknown Source)
at com.aspose.pdf.internal.l10t.ly.l0k(Unknown Source)
at com.aspose.pdf.internal.l10t.ly.lf(Unknown Source)
at com.aspose.pdf.internal.l10t.l0if.l0t(Unknown Source)
at com.aspose.pdf.internal.l10t.ly.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.convert(Unknown Source)
at com.aspose.pdf.Document.convert(Unknown Source)
at com.aspose.pdf.ADocument.convert(Unknown Source)
at com.aspose.pdf.Document.convert(Unknown Source)
at com.prova.pdfaconverter.Main.main(Main.java:36)
The document (about 18MB) used in our test is: https://1drv.ms/b/s!AtPn2aivHcLuhD3zGo5Ibg5GRcdM?e=hzlDkx
You can help us? Is our code correct? Can we optimize the heap utilization? We are trying other commercial libraries and Apose PDF seems the most intuitive, but we would not like to receive OutOfMemories at run-time.
Thanks!