Is there a way to include images and tables in Textfields with markup=html, when exporting a PDF using JasperReports?
使用JasperReports导出PDF时,有没有办法在textfields中使用markup = html包含图像和表格?
When I add a textfield with markup=html to my report, basic HTML support is provided out of the box, e.g.:
当我在报告中添加带有markup = html的文本字段时,提供了开箱即用的基本HTML支持,例如:
<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.
但是,似乎不支持更复杂的HTML。如果我做对了,就必须编写一个自定义MarkupProcessor来将传入的HTML转换为jrxml并将其插入JasperReports引擎来处理更复杂的示例。
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.
由于我们使用CKEditor来处理输入,因此使用的标记列表应该是可管理的。其次,我们已经使用Jsoup来解析和清理HTML,这可能对实现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.
有没有我可以建立的例子?正如我所说,我主要是寻找图像(img)和table(table,tr,td)支持。
If not, is there an alternative to achieve this using JasperReports?
如果没有,是否有替代方法可以使用JasperReports实现这一目标?
1 个解决方案
#1
4
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.
这似乎不可能。我们现在所做的是将图像插入jrxml中的预定义位置,并配置ckeditor的有限功能。另一种选择是从ckeditor中提取图像URL并将它们插入jrxml中的预定义位置,但我们现在不使用它。
#1
4
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.
这似乎不可能。我们现在所做的是将图像插入jrxml中的预定义位置,并配置ckeditor的有限功能。另一种选择是从ckeditor中提取图像URL并将它们插入jrxml中的预定义位置,但我们现在不使用它。