0

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.

  • **A** Which API do you use for PDF processing? ... **B** Please also show the stack trace of the exception. – mkl Nov 06 '14 at 09:30
  • I use Aspose for the PDF processing. The error was thrown while the customer was testing the application and unfortunately the stack trace was not given to me, which is why I tried replicating the error however I have not been successful in doing so. – Cody Anderson Nov 06 '14 at 15:36

2 Answers2

0

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.
Saqib Razzaq
  • 1,408
  • 1
  • 10
  • 10
0

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.