I have an issue in my program with a bookmark. When document loaded to Aspose Document object the bookmark place is not reflected as in Word xml.
Please see the attached document ForAspose.zip (9.7 KB)
(see also xml version) and see that the bookmark start is located in the same table as bookmark end, however, when loaded into Aspose Document object, bookmark start is not in the same table as in the document/xml.
Could you tell me why this is the case?
See the code example:
var template = @"{yourDir}\ForAspose.dot";
var document = new Document(template);
var bookmark = (Bookmark)document.Range.Bookmarks[0];
var bookmarkStartTable = bookmark.BookmarkStart.ParentNode.ParentNode.ParentNode.ParentNode;
var bookmarkEndTable = bookmark.BookmarkEnd.ParentNode.ParentNode.ParentNode.ParentNode;
Assert.IsTrue(bookmarkEndTable.Equals(bookmarkStartTable));
Thanks for your inquiry. You are facing the expected behavior of Aspose.Words. The input document has nested table. The outer table has one row with one cell. The BookmarkEnd is inside the outer table. Please check the attached DOM image for detail.
Please check the Document-Explorer example from Aspose.Words Github example repository.
Please check the output document in Document Explorer to check the BookmarkEnd node. If you still face problem, please share how are you creating the .xml file. We will investigate the issue and provide you more information on it.
Thank you. I have used the Document-Explorer, however, it looks like it is an older version of the one you are using. I have not been able to find the table from your screen shot. Could you share the version you are using?
Regarding the way I create the xml document is that I save the template provided as Word XML Document, then I can see that both BookmarkStart and BookmarkEnd are in the inner table.
Thank you for your response. I did not mean the version of Aspose.Words.dll being old, I meant the Document Explorer that is found on GitHub is and older version of the one you are using? I can see from your screen shot from the Document Explorer that it looks nicer Is it available?
Hmm, how can you tell that “the position of BookmarkEnd node is changed” when dot template saved as xml? I cannot see the bookmark end in the dot template.
Thanks for your inquiry. Please use the code of Document-Explorer from Aspose.Words Github example repository.
Please open your input document (ForAspose.dot) in MS Word and save it to DOCX or Word XML document. After saving the document, you can check the bookmark of document in Document Explorer.
Thank you for your response. I assume the the GitHub version you provided is the only publicly available.
I opened the .dot template with document explorer, then I saved it as .docx and opened the .docx with document explorer. I can see that BookmarkStart and BookmarkEnd are interpreted by Aspose differently (see the attached images DotAndDocx.zip (39.0 KB)
).
Can you explain why they are in different places depending on the format of the document?
The output DOCX generated by Document Explorer has the same output. It seems that you saved the DOTX to DOCX using MS Word and checked it in Document Explorer. Could you please confirm it? We will then log this issue in our issue tracking system.
Thanks for sharing the detail. We have tested the scenario 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-17986. You will be notified via this forum thread once this issue is resolved.