I'm trying to integrate BIRT (3.7) with my RCP application.
When generating a report chart converted into a image (PNG,SVG, e.t). I want during generation html report make a chart (image) embedded
How to make embedded image chart in html report?
The decision to setBaseImageUrl("url") does not suit me.
BIRT creates a column binding for each field in the data set. Drag the image element from the palette, and drop it in the detail row of the table. On Edit Image Item, select Dynamic image. Choose Select Image Data.
The BIRT Report Engine API (RE API) allows you to integrate the run-time part of BIRT into your application. This may mean integrating into a stand alone Java application, deploying as part of a servlet or embedding it within an RCP application.
I found a solution :)
...
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();
}
...
steps to insert image in birt design
Drag an image item from palette and follow the above steps. you can easily add image to your design. according to your cconvenience you can populate your design as html, doc, pdf etc
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