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

Free Support Forum - aspose.com

Table formatting revision has been lost after comparison of two documents

Hello. I need to compare two docx documents and show the result.

My code:
<span style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>
<span style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>Document sourceDocument = new Document(“sourceDoc.docx”);
<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>Document importDocument = new Document(“importDoc.docx”);<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>Document copyOrigin = (Document) sourceDoc.deepClone(true);
NodeCollection copyOriginNodes = copyOrigin.getFirstSection().getBody().getChildNodes();

sourceDoc.acceptAllRevisions();
importDoc.acceptAllRevisions();

sourceDoc.save(sourceDocBefore.html”, SaveFormat.HTML);
sourceDoc.compare(importDoc, “Parley”, new Date());
sourceDoc.save(sourceDocAfter.docx”, SaveFormat.DOCX);
sourceDoc.save(sourceDocAfter.html”, SaveFormat.HTML);


<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”><div style=“font-family: “Times New Roman”; white-space: normal;”>As you can see on screen1 column are shited to the right side (screen1) before compare in sourceDoc.docx
<div style=“font-family: “Times New Roman”; white-space: normal;”>But in html document sourceDocAfter,html after compare operation this revision has been lost (screen2) somehow.<div style=“font-family: “Times New Roman”; white-space: normal;”>But this revisions exists in docx document sourceDocxAfter,docx after compare operation.<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>
Hi Leonid,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for Java 16.6.0 and have not found the shared issue. Please use Aspose.Words for Java 16.6.0 and let us know if you have any more queries. We have attached the output documents with this post for your kind reference.

I tried to use 16.6.0 version but this version doesn’t work also. Now iam getting exception saving afterCompare.docx document to html. I’ve attached code and documents you need. After you reproduce and fix this error - please look at tables formatting also - it’s our main problem.


Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 3
at com.aspose.words.zzX.zzZ(Unknown Source)
at com.aspose.words.zzX.zzZ(Unknown Source)
at com.aspose.words.zz2.zzW(Unknown Source)
at com.aspose.words.zzZ0F.zzZmy(Unknown Source)
at com.aspose.words.zzYN.getWidth(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzYN.getX(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzYN.getX(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzYN.getX(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzX.zzZ(Unknown Source)
at com.aspose.words.zzX.zzQ(Unknown Source)
at com.aspose.words.zzW6.zzZ(Unknown Source)
at com.aspose.words.zzZ3Y.zzZ(Unknown Source)
at com.aspose.words.zzXI.zzvQ(Unknown Source)
at com.aspose.words.zzXI.zzY(Unknown Source)
at com.aspose.words.zzZCN.zzZBL(Unknown Source)
at com.aspose.words.zzZCN.zzU(Unknown Source)
at com.aspose.words.zzZC4.zzx(Unknown Source)
at com.aspose.words.zzZ21.zzS7(Unknown Source)
at com.aspose.words.zzAY.zzXK(Unknown Source)
at com.aspose.words.zzAZ.zz9G(Unknown Source)
at com.aspose.words.zzZQD.zzZ(Unknown Source)
at com.aspose.words.Document.updatePageLayout(Unknown Source)
at com.aspose.words.Document.zzXM(Unknown Source)
at com.aspose.words.Document.zzao(Unknown Source)
at com.aspose.words.zzZWP.zzZ(Unknown Source)
at com.aspose.words.zzZZJ.zzZX1(Unknown Source)
at com.aspose.words.zzZZJ.zzZXa(Unknown Source)
at com.aspose.words.zzZZJ.zzZXh(Unknown Source)
at com.aspose.words.zzZV9.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.parley.document.service.wrongCompare.main(wrongCompare.java:16)

Hi Leonid,

Thanks for sharing the detail. We have already answered your query here in this post. Please follow that thread for further proceedings.

Hello. Ok thanks. But it’s not out main problem. We’ve found a hack to solve this issue already - you just may save document to memory buffer and reopen it again instead of deep clone.

Please look at table formatting problem on screenshots.


Hi Leonid,

Thanks for your inquiry. The code shared in your first post, related to deepClone method, gets only child nodes of first section. Could you please share the code example here to reproduce this issue at our end? We will investigate the issue on our side and provide you more information.

Hello, Tahir. Thanks. Here is better code example, Get documents and screenshots from first post please,



<span style=“font-family: “Courier New”;”>Document sourceDocument = new Document(“sourceDoc.docx”);
<i style=“font-family: “Courier New”;”>Document importDocument = new Document(“importDoc.docx”);
<pre style=“font-family: “Courier New”;”>sourceDoc.acceptAllRevisions();
importDoc.acceptAllRevisions();

sourceDoc.save(sourceDocBefore.html”, SaveFormat.HTML);
sourceDoc.compare(importDoc, “Parley”, new Date());
sourceDoc.save(sourceDocAfter.docx”, SaveFormat.DOCX);
sourceDoc.save(sourceDocAfter.html”, SaveFormat.HTML);
Hi Leonid,

Thanks for sharing the detail. We have tested the scenario using following code example and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-13966. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Document sourceDoc = new Document(MyDir + "sourceDoc1.docx");
Document importDoc =
new Document(MyDir + "importDoc1.docx");
sourceDoc.acceptAllRevisions();
importDoc.acceptAllRevisions();

sourceDoc.save(
MyDir + "sourceDocBefore.html", SaveFormat.HTML);
sourceDoc.compare(importDoc,
"Parley", new Date());
sourceDoc.save(
MyDir + "sourceDocAfter.docx", SaveFormat.DOCX);
sourceDoc =
new Document(MyDir + "sourceDocAfter.docx");
sourceDoc.save(
MyDir + "sourceDocAfter.html", SaveFormat.HTML);

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.