BIRT How to make embedded image chart in html report?
Asked Answered
U

3

5

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.

Unpolite answered 20/7, 2012 at 8:58 Comment(0)
U
7

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();
}
...
Unpolite answered 25/7, 2012 at 16:0 Comment(2)
Did you have any issues with IE11 / Edge with this approach? @UnpoliteMerrick
it was 6 years ago, IE11 and Edge was not released yet, about current situation I am not sure, check and please share fresh knowledgeUnpolite
S
1

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

Syncarpous answered 20/7, 2012 at 9:19 Comment(1)
Thank you for your answer I mean not birt's element image. When generating a report chart converted into a image (PNG,SVG, e.t). I want during generation html report make ​​a chart (image) embeddedUnpolite
C
0

you can base64 encode the data in the image and embed it directly into the HTML or as a javascript variable

http://www.greywyvern.com/code/php/binary2base64/

this can be convenient, but makes your page larger.

Colloquium answered 20/7, 2012 at 9:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.