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.

archik
  • 455
  • 1
  • 5
  • 22

3 Answers3

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();
}
...
archik
  • 455
  • 1
  • 5
  • 22
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

Amith
  • 1,907
  • 5
  • 29
  • 48
  • 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) embedded – archik Jul 20 '12 at 11:34
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.

keefe
  • 46
  • 1