InsertHtml Seems to be Stripping Content

I am building a document using Aspose Words which is saved to a memory stream and displayed as part of a page. When building the document I am using InsertHTML to insert an to allow for some javascript calls. All this is working good. What I am having trouble with is I am also trying to give an id to this element so I can scroll to it on the page based on other actions. I included an id in the href tag and it is there when I do the InsertHTML, but apparently when the doc is saved as html it gets stripped out. I saved a copy to disk and when I look at it the id=… is gone but the rest of the href code is there. Why is this missing after the save and how can I preserve it?

Hi Curtis,

Thanks for your query. I have tried to understand your query and based on my understanding your want to insert HTML into your document by using DocumentBuilder.InsertHtml method. The HTML is like as follow:

<a id=“12345” href=“www.aspose.com”>Aspose
When you save the document the id=“12345” is dropped from output html. I would like to share with you that Aspose.Words mimics the same behavior as MS Word do. If you open the same HTML contents in MS Word and save these to html file, you will get the same behavior.

Hope this answers your query. Please let us know if you have any more queries.

So I am assuming from your answer that there is no way around this?

Do you know of a way to override this? It would help greatly if I could have it preserve the id.

We have Aspose Total, do you know if there is a way to accomplish what I am trying to do with any of your products?

Hi Curtis,

Thanks for your query. As I shared with you earlier
that Aspose.Words mimics the same behavior as MS Word do. MS Words also do not preserve ID in tag. However, you can insert HTML in your document as shown below, add ID after link. Aspose.Words preserve such HTML contents.

Aspose
After saving the document to html format, you can convert above html to (<a id =“12345” href=“www.aspose.com”>Aspose) by writing .NET code.

Please let us know if you have any more queries.