Hi,
We are a licenced Aspose User and we are using Aspose Words to compare word documents using Document.Compare method. We have noticed that for Aspose Words, when we try to compare two nearly same documents then the document that we get, from the Document.Compare method, has missing Bookmark node for some paragraphs, due to which our functionality breaks, as we generate IDs for the paragraph blobs from Bookmark ID. The version that we are currently using for Aspose Word is 23.8.0.
I have verified that the bookmarks are there when I try to parse the parse paragraphs without any document comparison, it only seems to be the case when we compare documents. I have also attached the word files for your reference. After the comparison, the bookmark for the paragraph 1 at page no. 1 is missing. Here is the paragraph text, just to be more specific:
Der Konzernabschluss der [ ORG ] wurde für das zum 31. [ DATE ] abgeschlossene [ DATE ] erstellt und umfasst die [ ORG ] (nachfolgend auch [ ORG ] oder [ ORG ]) und ihre Tochtergesellschaften sowie gemeinschaftliche Tätigkeiten (gemeinsam die „[ ORG ] [ ORG ]“ oder „[ ORG ]“) und assoziierte Unternehmen.
This is a very critical issue for our application and would really appreciate if you can help us in this regard at your earliest. Here is the sample code to reproduce the problem. Thanks.
var v1 = Path.Join("TestFiles/KV-2023.docx");
var document1 = new Document(v1);
var comments = document1.GetChildNodes(NodeType.Comment, true);
comments.Clear();
document1.Revisions.AcceptAll();
document1.RemoveMacros();
var v2 = Path.Join("TestFiles/KV-2024.docx");
var document2 = new Document(v2);
comments = document2.GetChildNodes(NodeType.Comment, true);
comments.Clear();
document2.Revisions.AcceptAll();
document2.RemoveMacros();
var doc = document1;
var author = Guid.NewGuid().ToString();
doc.Compare(document2, author, DateTime.Now);
var revisions = doc.Revisions;
revisions
.Where(rev => rev.RevisionType == RevisionType.FormatChange || rev.RevisionType == RevisionType.StyleDefinitionChange)
.ToList()
.ForEach(rev => rev.Accept());
document1.LayoutOptions.CommentDisplayMode = CommentDisplayMode.Hide;
var revisionOptions = document1.LayoutOptions.RevisionOptions;
revisionOptions.ShowInBalloons = ShowInBalloons.None;
revisionOptions.ShowRevisionMarks = false;
revisionOptions.ShowRevisionBars = false;
revisionOptions.ShowOriginalRevision = false;
var docxStream = new MemoryStream();
document1.Save(docxStream, SaveFormat.Docx);
var newDoc = new Document(docxStream);
foreach (var node in newDoc.Document.GetChildNodes(NodeType.Any, true))
{
if (node.NodeType == NodeType.Paragraph)
{
if (node.ParentNode.NodeType == NodeType.Comment)
continue;
var paragraph = (Paragraph)node;
if (!paragraph.HasChildNodes)
continue;
var blobId = GetBlobId(paragraph);
if (blobId == null)
{
Console.WriteLine("Not Found!");
}
}
}
KV-2023.docx (4.3 MB)
KV-2024.docx (4.7 MB)