I have written a Java program that deals with PDF's and at the end it runs the following code to optimize the file size of the PDF's that were created.
log.debug("Optimizing the PDF");
OptimizationOptions opt = new Document.OptimizationOptions();
opt.setRemoveUnusedObjects(true);
opt.setRemoveUnusedStreams(true);
opt.setLinkDuplcateStreams(true);
opt.setCompressImages(true);
opt.setImageQuality (90);
pdfDocument.optimizeResources(opt);
It works most of the time but recently it threw the following error java.lang.IllegalArgumentException: Map size (0) must be >= 1. I have not been able to replicate the error so I am unsure as to which line of code is throwing the error however my guess would be
pdfDocument.optimizeResources(opt);
My question is what are some of the possible causes for this error I have not been able to find any good information on this. I would also appreciate any links as well as any suggestions that are given.