BIRT How to make embedded graphics in an html report?

I am trying to integrate BIRT (3.7) with my RCP application.

When creating a report chart converted to an image (PNG, SVG, et). I want a chart (image) to be displayed during the generation of the html report

How to make inline graphics in html report?

The solution setBaseImageUrl ("url") does not suit me.

+5
source share
3 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();
}
...
+7
source

steps to insert image into birt design

Drag an image element from the palette and follow the steps above. You can easily add an image to your design. depending on your convenience, you can fill out your design as html, doc, pdf, etc.

+1
source
0

All Articles