I am using
org.docx4j.convert.in.xhtml.XHTMLImporterImpl
And when I call convert(html, ""); with following html:
<ul>
<li>first list item</li>
<li>
<table style="margin-left: auto; margin-right: auto; width: 75%; table-layout: fixed;">
<tbody>
<tr>
<td>
<p>ROW</p>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
I get the following stack trace:
java.lang.ClassCastException: class org.docx4j.org.xhtmlrenderer.css.constants.IdentValue cannot be cast to class org.docx4j.org.xhtmlrenderer.css.style.derived.LengthValue (org.docx4j.org.xhtmlrenderer.css.constants.IdentValue and org.docx4j.org.xhtmlrenderer.css.style.derived.LengthValue are in unnamed module of loader 'app')
at org.docx4j.convert.in.xhtml.ListHelper.getAbsoluteIndent(ListHelper.java:381)
at org.docx4j.convert.in.xhtml.TableHelper.setupTblPr(TableHelper.java:120)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.traverse(XHTMLImporterImpl.java:1020)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.traverse(XHTMLImporterImpl.java:1284)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.traverse(XHTMLImporterImpl.java:1284)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.traverse(XHTMLImporterImpl.java:1284)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.traverse(XHTMLImporterImpl.java:1284)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.traverse(XHTMLImporterImpl.java:825)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.convert(XHTMLImporterImpl.java:698)
I can tell that it is caused by margin-left and margin-right in the style attribute for the table because if I remove those convert() doesn't thrown an exception.
Does anyone know any workaround for this that doesn't involve removing margins from the table?
question from:
https://stackoverflow.com/questions/65904371/table-with-margins-attribute-as-list-item-throws-exception-classcastexception 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…