Convert List Labels in Word Document as Paragraphs <P> Tags in HTML (C# .NET)

When I converted a Word Document to HTML using MS Word, it converted everthing as paragraphs (p tags) even lists. When I used Aspose Word, it converted it as lists (list tags).

How to convert even lists as paragraphs (p tags)?

@dharanikumar7998,

Please use ExportListLabels.AsInlineText to get the desired output:

Document doc = new Document("C:\\temp\\list.docx");
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.Html);
htmlSaveOptions.PrettyFormat = true;
htmlSaveOptions.ExportListLabels = ExportListLabels.AsInlineText;
doc.Save("C:\\Temp\\21.3.html", htmlSaveOptions);
1 Like

Is it possible to convert sub bullet lists outside the list item tag, this type of bulleted lists in Word when converted to HTML forms a nested list, is there anyway/option to move it outside of that < LI > tag?

Screenshot (114).png (257.0 KB)

@dharanikumar7998,

Please ZIP and attach the following resources here for testing:

  • Your simplified Word DOCX document containing the nested list
  • Your expected HTML file showing the desired output. You can create this file manually by using MS Word or any other editor.

As soon as you get these pieces of information ready, we will then start further investigation into your scenario and provide you more information.

1 Like

Here is the word file and the desired HTML file. I added padding manually to the nested lists to show that indentation.op.zip (11.3 KB)

@dharanikumar7998,

We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-22043. We will further look into the details of this requirement and will keep you updated on the status of the linked ticket.

@dharanikumar7998,

Regarding WORDSNET-22043, we have completed the work on this issue and come to a conclusion to close this issue as “Won’t fix”. Please check the following analysis details:

Aspose.Words creates the following nesting list’s structure:

<ol>
    <li>
        <span>Item b</span>
        <ol>
            <li>
                <span>Item i</span>
            </li>
        </ol>
    </li>
</ol>

But, you expect a nested list inside the root list:

<ol>
    <li>
        <span>Item b</span>                     
    </li>
    <ol>
        <li>
            <span>Item i</span>
        </li>
    </ol>

And according to HTML specification (HTML Standard), only <li>, <script> and <template> elements are allowed inside <ol> (<ul>). At this case we can’t change the rule of HTML export.

So, we cannot implement the change, because the list structure you suggested is invalid in HTML. The expected HTML doesn’t pass validation at https://validator.w3.org/

In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Words’ forum.

Hi - First of all thank you for spending time on this. Is it possible to this:

Having each list element inside it’s own <ol>/<ul> tag. Please refer to the attached HTML, if you see there will be only one <li> inside each <ol>/<ul> tag. I was able to achieve this by manually adding a new line after each list item in the word file and then converted it using Aspose.

I added the new line manually so there will be only one <li> inside each <ol>/ <ul> to send you the desired output. I don’t want the new lines to be exported when saving to HTML and I can’t also do this manual process.desired.zip (12.0 KB)

@dharanikumar7998,

I am afraid, Aspose.Words cannot generate such HTML where each list item is exported as a separate list. Can you please elaborate your use-case a bit more to help us understand, what scenario such a HTML could be useful for? Please provide more information about the problem you are trying to solve and why can’t the lists generated by Aspose.Words be useful for you?