hello.
I need to compare 2 documents. First document is programatically generated in runtime. The other document is loaded from a file.
I’m getting the following exception if my first document contained revisions that were accepted and the Document was never saved
java.lang.IllegalArgumentException: Parameter name: index
at asposewobfuscated.zzFB.zzV2(Unknown Source)
at com.aspose.words.zzZQ8.zzGw(Unknown Source)
at com.aspose.words.zzZQ8.zzGx(Unknown Source)
at com.aspose.words.zzZQ8.zzGy(Unknown Source)
at com.aspose.words.zzOJ.zziU(Unknown Source)
at com.aspose.words.zzZ0A.zzZ3Z(Unknown Source)
at com.aspose.words.zzZ0A.zzZF(Unknown Source)
at com.aspose.words.zzOJ.zzR7(Unknown Source)
at com.aspose.words.zzOJ.zzZ(Unknown Source)
at com.aspose.words.zzOJ.zzj5(Unknown Source)
at com.aspose.words.zzZ0A.zzZ40(Unknown Source)
at com.aspose.words.zzZ0A.zzV(Unknown Source)
at com.aspose.words.zzXF.zzZ(Unknown Source)
at com.aspose.words.zzZ9G.zzZhS(Unknown Source)
at com.aspose.words.zzZ0A.zzZ40(Unknown Source)
at com.aspose.words.zzZ0A.zzV(Unknown Source)
at com.aspose.words.zz9Z.zzZYE(Unknown Source)
at com.aspose.words.zz9Z.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.compare(Unknown Source)
The exception is not thrown if I saved the first document prior to executing compare or if it never had any revisions.
So basically my workaround is to save the document prior to doing compare - that is an additional overhead and I’d like to avoid doing that, if possible.
Please advice if this is a bug and/or of another workaround.
Hi Mike,
Thanks for your inquiry. Could you please share following resources here for testing?
- Your input Word documents
- Please create a standalone Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.
I spend some time for research and found some details. I create document in runtime with bookmarks, where I saved ids from db. Incoming document don’t have bookmarks. So, in this case I catch error.
Hi Mike,
Thanks for sharing the detail. Please call Document.updatePageLayout method after creating Document from TextData. This will fix the shared issue. Please let us know if you have any more queries.
ExceptionTest run = new ExceptionTest();
Collection data = run.GenerateData();
com.aspose.words.Document sourceDoc = run.exportRedline(data);
sourceDoc.updatePageLayout();
Thanks. Could you tell me about revision at paragraph. In my demo(attached zip) for every new paragraph I created 2 documents and compare them, after all I copy to destination document. May be exist simple way add revision to paragraph? It seems after compare some bookmark moved to another paragraph. May be I do some wrong
Hi Mike,
Thanks for your inquiry.
Please use DocumentBuilder.Writeln instead of DocumentBuilder.InsertHtml method in your code. You are comparing the documents after inserting one paragraph in each document. We suggest you please create two complete documents from TextData and compare them using Document.Compare method. Hope this helps you.