简体   繁体   中英

java.lang.IllegalArgumentException: Map size (0) must be >= 1

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.

Most probably, this error is caused by some specific document(s). The best solution is to

  1. First find out which document caused this issue.
  2. Then report the issue in Aspose forums with the test file that caused this issue.

Well after a lot more tests it definitely has something to do with the size of the PDF's. The code works perfect with any normal size PDF it's the ones that start getting to the 1000's of pages that crash. I don't know if it's a time out issue or something else with how Aspose handles it but I will be escalating this to Aspose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM