html添加图片组件,如何使用html组件导出嵌入图像(base64,data uri)的HTML文本?

这是一个很好的挑战,问题是它不受支持,但并不意味着它无法完成.

html组件使用JEditorPane将html呈现为图像,并且“data:”没有默认的协议处理程序.

然而,这个优秀的answer到Joop Eggen显示了如何添加一个.

jrxml(htmlComponentBase64.jrxml)

Hi, I am through HTML CODE using HTML Component

Japser Architecture"]]>

java的

添加Joop Eggen的协议处理程序(记得将他归类,也许是一个不错的upvote)并执行这个java代码,在这种情况下导出为pdf

public class TestReport {

public static void main(String[] args) throws JRException {

Handler.install(); //Install Joop's protocol handler

//Compile report and fill, no datasource needed

JasperReport report = JasperCompileManager.compileReport("htmlComponentBase64.jrxml");

JasperPrint jasperPrint = JasperFillManager.fillReport(report, new HashMap());

//Export to pdf

JRPdfExporter exporter = new JRPdfExporter();

exporter.setExporterInput(new SimpleExporterInput(jasperPrint));

exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("pdf/htmlcomponentbase64.pdf"));

SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();

exporter.setConfiguration(configuration);

exporter.exportReport();

}

}

享受结果

SDzbX.png

不是最好的报告,但显示图像

I have added a 07004 in jasper-reports community, to include a data protocol handler in future release

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值