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 documents and create an instance of LayoutEnumerator and LayoutCollector then the document that we get, from the Document.Compare method after accepting revision, has no BookmarkStart and BookmarkEnd node for many 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 24.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 bookmarks for the paragraphs in the starting pages are missing. Here is also the code to reproduce the issue:
var v1 = Path.Join("TestFiles/v1.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/v2.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());
var _enumerator = new LayoutEnumerator(doc);
var _collector = new LayoutCollector(doc);
var parentPara = (Paragraph)revisions[12].ParentNode;
var bookmarkStart = (BookmarkStart)parentPara.GetChildNodes(NodeType.Any, false)
.FirstOrDefault(child =>
child is BookmarkStart bookmark && bookmark.Name.StartsWith("Para"));
var bookmarkName = bookmarkStart?.Name;
If you check the bookmarkStart is null. This is a very critical issue for our application and would really appreciate if you can help us in this regard at your earliest. Thanks.
v1.docx (70.4 KB)
v2.docx (366.7 KB)