BookmarkStart and BookmarkEnd not in the same table

Hi,

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,
Lukasz

@acturisaspose

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.

Hi Tahir,

Thank you for your response. I have checked the screen shot of yours. Could you please tell me what application you use to inspect the DOM?

When I saved the .dot template as .xml I can see that the BookmarkEnd is in the nested table, not in the outer one.

ForAspose.png (56.6 KB)

Thank you,
Lukasz

@acturisaspose

Thanks for your inquiry.

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.

Hi Tahir,

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,
Lukasz

@acturisaspose

Thanks for your inquiry.

We have used the latest version of Aspose.Words for .NET 19.1. Please check the attached image of ForAspose.dot.

When you save the document to XML format using MS Word, the position of BookmarkEnd node is changed. Please check the attached image of XML document.

Hi Tahir,

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 :slight_smile: 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.

Thank you,
Lukasz

@acturisaspose

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.

Hi Tahir,

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?

Thank you,
Lukasz

@acturisaspose

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.

Hi Tahir,

Yes, I opened the .dot template with MS Word and saved it as .docx, then I opened the .docx with Document Explorer.

Thank you,
Lukasz

@acturisaspose

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.

We apologize for your inconvenience.

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