We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Remove Bookmarked Anchored Table of Contents (_TOC) Locations during Converting Word DOC Document to HTML using C# .NET

After Converting a Word Document into Html File, I case see some extra anchor tags with name starting “_Toc” inside some random Html elements. What could be the reason for that? How can I get rid of these extra anchor tags?
<p style="margin-top:5pt; margin-bottom:5pt"><a name="_Toc35004850"><span>2020 Year....</span></a></p>


These represent the locations where particular Table of Content (TOC field) hyperlinked entries are supposed to jump to. You can remove them (Bookmarked locations) by using the following code:

Document doc = new Document("C:\\temp\\in.doc");

foreach (Bookmark bm in doc.Range.Bookmarks)
    if (bm.Name.StartsWith("_Toc"))

HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.Html);
htmlSaveOptions.PrettyFormat = true;

doc.Save("C:\\temp\\20.10.html", htmlSaveOptions);

Thank You @awais.hafeez.