Bookmark placement issue with bullet point list while converting docx to html

Hello,

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

Link: NuGet Gallery | Aspose.Words 24.7.0

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

I have attached below files:

  1. Original Document(TestDocument.docx)
    TestDocument.docx (15.0 KB)

  2. Converted Document(DocxToHTML.html file inside the DocxToHTML.zip folder)
    DocxToHTML.zip (7.4 KB)

If you observe the docx file then bookmark1 is given just before the ‘T’ character of Test1 line but in converted html bookmark1 shows before the bullet point 1.1

Second bookmark2 is given after the character ‘T’ of the Test2 line and it shows perfectly after T only in converted html file.

Please suggest a way for bookmark1 such that after the conversion it shows bookmark at the start of the sentence not at the start of bullet point.

@ankit.chhelavda The bookmark is at the beginning of the paragraph, since bullet is considered as a part of the paragraph, the behavior is expected. As a workaround, you can insert a run before the bookmark start. For example see the following code:

Document doc = new Document(@"C:\Temp\in.docx");

Run hiddenRun = new Run(doc, " ");
hiddenRun.Font.Size = 0;
foreach (Bookmark bk in doc.Range.Bookmarks)
{
    bk.BookmarkStart.ParentNode.InsertBefore(hiddenRun.Clone(true), bk.BookmarkStart);
}

HtmlFixedSaveOptions opt = new HtmlFixedSaveOptions();
opt.PrettyFormat = true;
opt.ExportEmbeddedCss = true;
opt.ExportEmbeddedFonts = true;
opt.ExportEmbeddedImages = true;
opt.ExportEmbeddedSvg = true;

doc.Save(@"C:\Temp\out_html_fixed.html", opt);