Is there a way to include images and tables in Textfields with markup=html, when exporting a PDF using JasperReports?
When I add a textfield with markup=html to my report, basic HTML support is provided out of the box, e.g.:
<textField>
<reportElement .../>
<textElement markup="html"/>
<textFieldExpression><![CDATA["<html>some <b>bold</b> text</html>"]]></textFieldExpression>
</textField>
However, more complex HTML seems not to be supported. If I got that right, one would have to write a custom MarkupProcessor to transform the incoming HTML to jrxml and plug it into the JasperReports engine to handle more complex examples.
Since we use a CKEditor to handle the input, the list of used tags should be manageable. Secondly, we already use Jsoup to parse and cleanup HTML, which might be useful implementing the MarkupProcessor.
Is there an example I could build on? As I said, I'm mainly looking for image (img
) and table (table
, tr
, td
) support.
If not, is there an alternative to achieve this using JasperReports?
It seems impossible indeed. What we do now instead is inserting images at predefined locations in the jrxml instead, and config limited functionality of ckeditor. Another option would be to extract the image urls from ckeditor and insert them at predefined locations in the jrxml, but we don't use that right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With