Page 1 of 1

Bug when placing <table> with “align=center” inside an <li>

PostPosted: Mon Nov 14, 2016 9:47 pm
by pleft
In short, the following code crashes in latest (3.3.1) docx4j-ImportXHTML:

Code: Select all
public class PlainTests {

    static final String TEST_STRING = "<html>" +
            "<body>" +
            "<ul><li>" +
            "<table align=\"center\" border=\"1\">" +
            "<tr><td>1</td></tr>" +
            "</table>" +
            "</li></ul>" +
            "</body>" +
            "</html>";
    public static void main(String[] args) throws ParserConfigurationException, Docx4JException {

        WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.A4, true);

        XHTMLImporterImpl XHTMLImporterForContent = new XHTMLImporterImpl(wordMLPackage);
        wordMLPackage.getMainDocumentPart().getContent().addAll(XHTMLImporterForContent.convert(TEST_STRING, null));
        wordMLPackage.save(new File("test.docx"));
    }
}


with
Code: Select all
Exception in thread "main" java.lang.ClassCastException: org.docx4j.org.xhtmlrenderer.css.constants.IdentValue cannot be cast to org.docx4j.org.xhtmlrenderer.css.style.derived.LengthValue
    at org.docx4j.convert.in.xhtml.ListHelper.getAbsoluteListItemIndent(ListHelper.java:306)


For more info please see the stackoverflow link: http://stackoverflow.com/questions/4058 ... nside-an-l