We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Save as PDF causing IllegalArgumentException: error: addition of a duplicate key to a dictionary

We have a document that with Aspose Words 16.8 converted to PDF just fine. We are in the process of upgrading to Aspose Words 18.7 and it fails to load with the following exception:

com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.FileFormatUtil.zzZ(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.napersoft.test.AsposeCreatePDF.main(AsposeCreatePDF.java:72)
Caused by: java.lang.IllegalArgumentException: error: addition of a duplicate key to a dictionary
at asposewobfuscated.zzZ.zzY(Unknown Source)
at com.aspose.words.TableStyle.zzZ(Unknown Source)
at com.aspose.words.zzZ1I.zzU(Unknown Source)
at com.aspose.words.zzZ1I.zzY(Unknown Source)
at com.aspose.words.zzZ25.zzZoL(Unknown Source)
at com.aspose.words.zzZ25.read(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
… 5 more

I have attached a ZIP file with the program I used (both source and compiled) and the document Test.rtf which we are trying to convert to PDF.2018-07-27_CreatePDFIssue.zip (116.3 KB)

@sherter,

Thanks for your inquiry. We have tested the scenario and noticed that the exception is thrown while importing document into Aspose.Words’ DOM. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-17263. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

We have tested the scenario using Aspose Words 16.8 and faced the same exception.

We are using Aspose-Words for Java, will the fix for Words.Net also be in the Java version?

@sherter,

Yes. The latest version of Aspose.Words for Java is completely auto-ported from .NET, i.e. we do not write code for Aspose.Words for Java; it is generated out automatically from C# code of Aspose.Words for .NET. In your case, the issue which was logged with WORDSNET prefix, would be auto resolved for Java variant of Aspose.Words. Your problem (WORDSNET-17263) will be fixed in Aspose.Words for Java as soon as the linked issue is resolved. Hope, this helps.

The issues you have found earlier (filed as WORDSNET-17263) have been fixed in this Aspose.Words for .NET 18.9 update and this Aspose.Words for Java 18.9 update.

I must of missed the email on this, I came to check on the case issue and found out it was fixed a while ago. I tested it and it is not crashing, however the RTF is not rendering properly compared to the DOCX. The first table width is wrong. I have attached the source for the program, the DOCX and RTF documents, and the PDFs created from Aspose.Words for java 18.9.2018-09-28_CreatePDFIssue.zip (310.8 KB)

@sherter,

Thanks for your inquiry. Please do not call the Document.updateTableLayout method to get the desired output.

I commented out the updateTableLayout and it now works. I also noticed that the call was only in my test code and not in our production code. Thanks for your help.

A post was split to a new topic: IllegalArgumentException is thrown when document is saved to PDF