We are receiving a “java.lang.OutOfMemoryError” during the final save of a PDF after converting certain image files to PDF. Below is the section of code.
if(chunkCount > 0) {
result = getResultTarget(ZIP_FORMAT);
try (OutputStream output = result.getOutputStream()){
saveAndClearPdf();
stitchAndCleanChunks(output);
}
} else {
result = getResultTarget(PDF_FORMAT);
try (OutputStream output = result.getOutputStream()){
pdf.optimize();
pdf.optimizeResources(getOptimizationOptions());
LOGGER.debug("Saving final PDF");
pdf.save(output);
}