NullPointerException when setting optimization options during a PDF merge

java.lang.NullPointerException

at com.aspose.pdf.ADocument.startOperation(Unknown Source)

at com.aspose.pdf.ADocument.m1(Unknown Source)

at com.aspose.pdf.ADocument.optimizeResources(Unknown Source)

at com.aspose.pdf.Document.optimizeResources(Unknown Source)

Using version aspose-pdf-11.2.0.

Can you tell why this a null pointer is thrown in this case? This is the code we use.

com.aspose.pdf.Document targetPdf = new com.aspose.pdf.Document(is);
Document.OptimizationOptions opt = new Document.OptimizationOptions();
opt.setLinkDuplcateStreams(true);
opt.setRemoveUnusedObjects(true);
opt.setRemoveUnusedStreams(true);
opt.setCompressImages(true);
opt.setImageQuality(10);
targetPdf.optimizeResources(opt);

com.aspose.pdf.Document sourcePdf = new com.aspose.pdf.Document(inputStream);
sourcePdf.optimizeResources(opt);
targetPdf.getPages().add(sourcePdf.getPages());

Hi Dave,


Thanks for contacting support.

The problem appears to be document specific, so we request you to please share the resource file, so that we can test the scenario in our environment. We are sorry for this inconvenience.