Page 1 of 1

Html code to DOCX - problem with ul and li balises

PostPosted: Mon Aug 05, 2013 11:51 pm
by Peter Lomax
Hi,

I have a problem to convert nested ul and li html balises to DOCX.

I have something like that in my HTML code :

Code: Select all
<html>
<body>
<h3>content</h3>
  <ul>
        <li>content</li>
        <li>content
           <ul>
              <li>content</li>
              <li>content</li>
           </ul>
        </li>
        <li>content
           <ul>
              <li>content
                 <ul>
                    <li>content
                       <ul>
                          <li>content</li>
                          <li>content</li>
                       </ul>
                    </li>
                 </ul>
              </li>
           </ul>
        </li>
  </ul>
</body>
</html>


I convert it
Code: Select all
XHTMLImporter.convert(htmlCode, null, template);


And I get all of my content at the same level in my DOCX file.

• Content
• Content
• Content
• …

Please let me know if I can solve this problem.

Re: Html code to DOCX - problem with ul and li balises

PostPosted: Wed Aug 07, 2013 1:47 pm
by jason
Hi Peter, Just a quick note to let you know I am intending to look into this later today or tomorrow. cheers .. Jason

Re: Html code to DOCX - problem with ul and li balises

PostPosted: Thu Aug 08, 2013 12:54 am
by Peter Lomax
Hi Jason,

Thanks for your reactivity. But i have already do the modification in your library to solve my problem. I give you the file in attachment.

Peter

Re: Html code to DOCX - problem with ul and li balises

PostPosted: Thu Aug 15, 2013 12:58 pm
by jason
https://github.com/plutext/docx4j-Impor ... 60afe89dde is a substantial reworking of list handling, including support for nested lists.

Instead of using 2 canned predefined lists, one for OL and another for UL, this implementation will create lists on the fly, based on the CSS encountered.

Alternatively, if you have list styles defined in your docx, and a matching @class on your OL|UL, it will use the Word list style instead of the CSS.

Re: Html code to DOCX - problem with ul and li balises

PostPosted: Wed Oct 23, 2013 2:38 am
by Roil
Jason,

I am a little confused by the CSS portion. What would I need to add to the UL tags in the following example HTML code for the ListHelper to properly multi-level it through conversion to DOCX?

Code: Select all
<ul>
  <li> Outer 1 </li>
  <li> Outer 2 </li>
    <ul>
      <li> Inner 1 </li>
      <li> Inner 2 </li>
    </ul>
  <li> Outer 3 </li>
</ul>


Thanks

Re: Html code to DOCX - problem with ul and li balises

PostPosted: Wed Oct 23, 2013 8:11 am
by jason
Nothing. With the current dev trunk tip of docx4j-ImportXHTML I just tested this with, it works as is.