Multiline bookmark issue with Microsoft word to html conversion


Currently, we are trying to convert word(docx/doc) file to html with the help of nuget package of Aspose.Words with version number 23.4.0.

Link: NuGet Gallery | Aspose.Words 23.4.0

For the conversion, we are using HtmlFixedSaveOptions as we want html to look same as the word file.

There is a multiline bookmark in the word file and while converting to html Aspose breaks it into multiple span tag and not preserving it in a single anchor tag.

Because of this scenario we are not able to identify the bookmark text properly and it has become the issue for us.

Is there any way to preserve multiline bookmark text of word file in a single anchor/span tag such that it can be identified that what length of text is an actual bookmark text from that sentence?

Please check below html code for better understanding. In below Html code, the text marked with bold letters is the actual bookmark text from the whole sentence but as this is the multiline statement in word file, Aspose is not able to wrap that text in a single anchor/span tag.

<a name="TermDefinition3" style="left:397.47pt; top:15.98pt;">
<span class="awspan awtext001" style="left:397.47pt; top:16.38pt; line-height:13.41pt;">**multiline text** </span>
<span class="awspan awtext001" style="left:0pt; top:32.36pt; line-height:13.41pt;">**with bookmark** This is a multiline text with bookmark. </span>

@ankitchhelavda Unfortunatly, Aspose.Words don’t support multiline bookmarks. We have logged WORDSNET-22474 feature request. Sorry for any inconvenience caused.

@vyacheslav.deryushev is there something we can modify the html while converting from docx to html using DocumentBuilder class?
Something like shown/replied in below comment?

@ankitchhelavda Unfortunatly, there is no workaround for the HtmlFixed format.

@vyacheslav.deryushev Ok.

Secondly, we tried with HtmlSaveOptions format as well and in that we are getting multiline bookmarks properly wrapped in anchor tag. But with HtmlSaveOptions we are not able to maintain the view of the HTML same like docx file.

Is there any way in HtmlSaveOptions format, we can maintain the view like it shows when we use HtmlFixedSaveOptions format?

Please check below HTML which we received with HtmlSaveOptions and it is exactly what we want.

<a name="TermDefinition3"><span>multiline text with bookmark</span></a>

@ankitchhelavda Unfortunatly, using HtmlSaveOptions you can’t save view like in word document. I have created an issue about bookmarks in HtmlFixedSaveOptions. When we analyze it, we can provide more information.

@vyacheslav.deryushev ok

@ankitchhelavda We have finished analyzing the problem and are ready to close it as a “Not a Bug”.
When rendering in HtmlFixed, the document is first converted to the internal APS model, which does not preserve the logical structure of the document. In APS, bookmarks are positions, not areas, and they cannot enclose other nodes. As a result, only the initial position of the bookmark is preserved: the point to which the document viewer should move when navigating to the bookmark.
Unfortunatly, it’s a technical limitation of the HtmlFixed format.