Search code examples
javahtmldocxdocx4j

docx4j convert w:numPr convert to <ul>?


Does docx4j conversion to html support converting w:numPr elements to an html list?

Attempting to have roundtrip html->docx->html. Experiencing a problem on the return from docx->html - the w:numPr become p and not converted back to the original ul.

For testing, I created a new docx, added a bullet list and converted it to html

Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

Creates p elements rather than ul. Does docx4j support creation of from w:numPr rather than p? If so, how?

Thanks!


Solution

  • As you have observed, docx4j doesn't current convert numbered paragraphs into HTML list items.

    It would be fairly straightforward to do that, but a bit more effort to wrap the list items in appropriate ol or ul elements.

    UPDATE

    This commit adds ol or ul elements and list items, provided you set:

        SdtWriter.registerTagHandler("HTML_ELEMENT", new SdtToListSdtTagHandler()); 
    

    and are using XSL for the output method.