Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Apr 05, 2023 6:16 am

Hi Team,

I have encountered couple of issues when converting HTML to word document with a hierarchy of bullet lists.
For example,
<ol>
<li>One
<ol type = "a"><li>a</li><li>b</li></ol>
</li>
</ol>

The word document generated doesn't have bullet list type as lower alpha but is decimal
Output is
1. One
1. a
2. b

Expected is:
1. One
a. a
b. b

If a list contains margin-left styling then word document is not accurately showing the margin. Maybe Spire doc doesn't work with list margins as I am expecting. In HTML when I indent a list, margin-left is added to <li> tag.
<ol>
<li style="margin-left:8px">One</li>
<li style="margin-left:8px">Two</li>
</ol>

But if I strip off the margin from the style then the generated word document is as expected.

I am attaching sample code and the output word document for your reference.

Can you please take a look at the two issues I have mentioned.

I am using .NET core 6.0 and I have also tried the sample code on .NET framework 4.7.1

Appreciate your support!

Thank you,
Jalpa

jalpaashara
 
Posts: 21
Joined: Wed Jun 22, 2022 8:12 pm

Wed Apr 05, 2023 7:26 am

Hello,

Thanks for your inquiry.
I tested the code for the two issues you mentioned using the latest commercial version (Spire.Doc Pack (hot fix) Version: 11.3.1), but neither of them reproduced the issues you mentioned. The attachment is my test result file. If you are not using this version, I suggest you try this version first. If the issue still exists after trying, please provide your test environment, such as OS info (E.g. Windows 10, 64-bit) and region setting (E.g. China, Chinese).

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Apr 05, 2023 5:08 pm

Hi Annika,

I have tried it with latest hotfix and I get the same result where list type is alpha lower but word document converts it to decimal.
List type i.e. lower alpha, roman etc. have been inconsistent when I run html to word conversion. Can you please use the html in the source code that I have provided and try running the sample data in there. Thanks!

Regarding margins, what should I provide as margin in html if I want my bullet list to be indented on the right side in the word document as show in the screen shot and result.docx attached.
margins.png

result.zip


I have one more question, lists have startat property on <ol> tag that helps with continuation of numbering. When I convert html with such list to word, it looks like in word the list even though shows correct number but it start with new list instead of continuing from previous list. How do I set up numbering value to continue from previous list.
set numbering value.png


I use Windows 11 64-bit operating system and my region setting is United States and English

Thank you for the support!

jalpaashara
 
Posts: 21
Joined: Wed Jun 22, 2022 8:12 pm

Thu Apr 06, 2023 7:20 am

Hello,

Thank you for your feedback.

I tested your complete HTML code and reproduced the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREDOC-9253. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.
Additionally, please use the following code to set the "Continue from previous list" option you mentioned.
Code: Select all
 Document document = new Document();
 document.LoadFromFile("input.docx");
 foreach (Section section in document.Sections)
 {
     foreach (DocumentObject obj in section.Body.ChildObjects)
     {

         if (obj is Paragraph)
         {
             Paragraph para = obj as Paragraph;
             if (para.Format.OutlineLevel.Equals(ListType.Numbered))
             {
                 //Continue last list
                 para.ListFormat.ContinueListNumbering();
             }
         }
     }
 }
 document.SaveToFile("result.docx", FileFormat.Docx);

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Apr 07, 2023 11:19 pm

Hi Annika,

Thanks for the code snippet, it works.

Just want to make sure that both issues (margins and bullet types) will be addressed as part of the ticket number SPIREDOC-9253.

Please note that bullet types is a P0 issue, correct numbering type (decimal, alpha, roman etc) based on ol type = 1, i, I, a, A etc. is critical for us. Appreciate if this can be speed tracked.

Thank you for your support.

--Jalpa

jalpaashara
 
Posts: 21
Joined: Wed Jun 22, 2022 8:12 pm

Mon Apr 10, 2023 9:01 am

Hi,

Thank you for your feedback.
As you mentioned, the margin issue is caused by incorrect parsing of the hierarchy in our product's list. Our development team will investigate and fix these issues together with the numbering type issue. Once there is any update, I will inform you promptly.
Thank you for your understanding.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Apr 12, 2023 11:55 pm

Hi Annika,

Thanks for confirming.

Regarding bullet issue, if it helps I have narrowed the scenario down to the style property's value

The issue occurs when there is a semicolon missing at end of style property of the list element, below is an example:
Code: Select all
<div>
    <h1>Without semicolon at the end of the list style</h1>
    <ol>
        <li style="text-align:justify; margin-bottom:16px; list-style-position:outside"> One
            <ol type="a">
                <li style="text-align:justify; margin-bottom:16px; list-style-position:outside"> Lower Alpha 1 </li>
                <li style="text-align:justify; margin-bottom:16px; list-style-position:outside"> Lower Alpha 2 </li>
            </ol>
        </li>
        <li style="text-align:justify; margin-bottom:16px; list-style-position:outside"> Two </li>
    </ol>
</div>


Below is an example where I added semi colon at the end of the style property and the export to word generated the bullet list numbering as expected.
Code: Select all
<div>
    <h1>With semicolon at the end of the list style</h1>
    <ol>
        <li style=text-align:justify; margin-bottom:16px; list-style-position:outside;\"> One
            <ol type="a">
                <li style=text-align:justify; margin-bottom:16px; list-style-position:outside;\"> Lower Alpha 1 </li>
                <li style=text-align:justify; margin-bottom:16px; list-style-position:outside;> Lower Alpha 2 </li>
            </ol>
        </li>
        <li style=text-align:justify; margin-bottom:16px; list-style-position:outside;> Two </li>
    </ol>
</div>


Missing of the semicolon attribute doesn't break the html and browsers render such lists accurately.

jalpaashara
 
Posts: 21
Joined: Wed Jun 22, 2022 8:12 pm

Thu Apr 13, 2023 9:47 am

Hello,

Thank you for providing the information.

I will submit the information you provided to the development team, which will help them investigate and fix this issue. Thank you again for providing the survey information.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Aug 18, 2023 1:11 am

Hello,

Glad to inform that we just released Spire.Doc Pack(hot fix) Version:11.8.9 which fixed the issue of SPIREDOC-9253, please download it from the following links to test.
Website link: https://www.e-iceblue.com/Download/download-word-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.Doc/11.8.9

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Doc