Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BIRT How to make embedded image chart in html report?

Tags:

java

rcp

birt

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.

like image 923
archik Avatar asked Jul 20 '12 08:07

archik


People also ask

How do I display an image in a BIRT report?

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.

What is BIRT Report Engine?

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.


2 Answers

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();
}
...
like image 76
archik Avatar answered Oct 19 '22 08:10

archik


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

like image 1
Amith Avatar answered Oct 19 '22 08:10

Amith