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?
Ex:
<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"))
bm.Remove();
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.Html);
htmlSaveOptions.PrettyFormat = true;
doc.Save("C:\\temp\\20.10.html", htmlSaveOptions);