-->

HTML String is not parsed with iText XML parser

2019-09-20 05:17发布

问题:

I am unable to parse below HTML string using iText's xmlworker-5.5.9.jar

String FOOTER = "<table width=\"100%\" border=\"0\"><tr><td><span class=\"bold\">Footer</span></td><td align=\"right\">Some title</td></tr></table>";

by below helper class:

XMLWorkerHelper.parseToElementList(FOOTER, CSS);

I am getting below error:

Exception in thread "main" java.lang.NoSuchMethodError: com.itextpdf.tool.xml.html.pdfelement.NoNewLineParagraph.setMultipliedLeading(F)V

I saw iText's documentatin and answer in this forum too.

Any help will be appreciated. Thanks.

回答1:

The above exception is beacause of uncompatibility of xmlWorker.jar and itextpdf.jar. So, to avoid above exception use single itextpdf.jar in your project and that is above itextpdf-5.5.1.jar version.