HI,
i running file is aspose pdf version 23.7 on linux and JAVA version
java version “1.8.0_241”
Java™ SE Runtime Environment (build 8.0.6.7 - pxi3280sr6fp7-20200312_01(SR6 FP7))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux x86-32-Bit 20200219_440062 (JIT enabled, AOT enabled)
OpenJ9 - 3088245
OMR - eb95a4d
IBM - 83517b6)
JCL - 20200310_01 based on Oracle jdk8u241-b07
and get the next exception:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.aspose.pdf.internal.l7v.l1u.lI(Unknown Source)
at com.aspose.pdf.internal.l10n.lk.lI(Unknown Source)
at com.aspose.pdf.internal.l10n.ld.l0j(Unknown Source)
at com.aspose.pdf.internal.l4t.lu.lI(Unknown Source)
at com.aspose.pdf.internal.l4t.lu.lI(Unknown Source)
at com.aspose.pdf.OperatorCollection.lb(Unknown Source)
at com.aspose.pdf.OperatorCollection.ld(Unknown Source)
at com.aspose.pdf.OperatorCollection.size(Unknown Source)
at com.aspose.pdf.OperatorCollection$lI.hasNext(Unknown Source)
at com.aspose.pdf.ImagePlacementAbsorber.lf(Unknown Source)
at com.aspose.pdf.ImagePlacementAbsorber.lI(Unknown Source)
at com.aspose.pdf.ImagePlacementAbsorber.visit(Unknown Source)
at com.aspose.pdf.Page.accept(Unknown Source)
at com.aspose.pdf.PageCollection.accept(Unknown Source)
at Sanitization.Sanitizers.PdfSanitizer.handlePictures(PdfSanitizer.java:49)
my relevant part of the code is:
private void handlePictures(Document doc, CleaningResponse response, CleanOptions ops) {
ImagePlacementAbsorber absorber = new ImagePlacementAbsorber();
doc.getPages().accept(absorber);
for (Page page: doc.getPages()) {
XImageCollection xImageCollection = page.getResources().getImages();
for (int i = 1; i <= xImageCollection.size(); i++) {
XImage origImage = xImageCollection.get_Item(i);
origImage.save(origImagePng, ImageType.getPng());
bytes = origImagePng.toByteArray();
if (bytes == null) {
logger.warning("Null image data");
continue;
}
do somthing
}
try {
xImageCollection.replace(i, new ByteArrayInputStream(picSanitizer.sanitize(bytes)));
} catch (Exception e) {
logger.warning(e.getMessage());
response.setPartResult(SanitizablePart.Pictures, PartResult.Failed);
}
} else {
do something
}
}