我正在尝试将BIRT(3.7)与我的RCP应用程序集成.
生成报告图表时转换为图像(PNG,SVG,et).我想在生成html报告时制作一个图表(图像)嵌入
如何在html报告中制作嵌入式图像图表?
setBaseImageUrl("url")的决定不适合我.
我找到了解决方案:)
...
IReportRunnable design = engine.openReportDesign(designInputStream);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
IRenderOption options = null;
switch (format) {
case ReportFormats.HTML_REPORT:
options = new HTMLRenderOption();
options.setOutputFormat(HTMLRenderOption.HTML);
options.setOutputStream(outputStream);
options.setSupportedImageFormats("PNG");
((HTMLRenderOption) options).setEmbeddable(true);
options.setImageHandler(new HTMLServerImageHandler() {
@Override
protected String handleImage(IImage image, Object context,
String prefix, boolean needMap) {
String embeddedImage = null;
//embeddedImage = convert image.getImageStream() to Base64 String
return "data:image/png;base64," + embeddedImage;
}
});
break;
...
if (options != null) {
task.setRenderOption(options);
task.run();
task.close();
engine.destroy();
}
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4187 次 |
| 最近记录: |