I have a BIRT report with an image in the master page.
My BIRT design file:
I embedded a png inside the report and it generated the following XML after the body
tag:
<list-property name="images">
<structure>
<property name="name">filename.png</property>
<property name="type">image/png</property>
<property name="data">
BASE64 of the image
</property>
</structure>
</list-property>
Then, I have included it into the master page, adding this element:
<image id="828">
<property name="source">embed</property>
<property name="imageName">filename.png</property>
</image>
Behaviours of my BIRT design file:
Then, If I run the preview from the BIRT designer it works great with both HTML and PDF output. If I render it using IPDFRenderOption
(from my software) it generates the correct pdf
fine. But if I use HTMLRenderOption
, then the image is not embeded into the HTML report, but it is rendered with something like:
<img src="file:/.../apache-tomcat-7.0.35/design11.png">
What I expect:
While I expected something like:
<img src="data:image/png;base64,BASE64 STUFF THAT I PUT IN THE LIST-PROPERTIES ">
So, how can I let BIRT, when executed with HTMLRenderOption
, to embed my image into the HTML file instead of creating a link to it?
I solved this by adding two different images to the masterpage of the report:
Setting of the image in the PDF output:
Since the
PDF
is well rendered, I leaved the image as I wrote in the question, and I set off the visibility of this image in the HTML outputSetting of the image in the HTML output:
Then, in the master page, I added a new image. This time I haven't set it as embedded. Instead I set it as referenced by an
URI
. AsURI
I set thebase64 URI
that I need in myHTML
output. Basically, I added to theXML
of the report the following image:I then set the image to be visibile only for the
HTML
output.In this way
BIRT
renders animg
tag with theURL
i put in theXML
, whatever it is. And thus, it puts thedata:image/png;base64, BASE 64 OF MY PNG IMAGE
asurl
. And thus it embeds the image in theHTML
output.Adding images from the database in your table:
BIRT supports the images inside
blob
fiels, and can manage in adding them to your report. To see how, see there: http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.birt.doc%2Fbirt%2Flayout.5.7.htmlIf it does not works, you can manage inserting a dynamic value on your url, still without editing the scripts (but of course using a bit of Javascript to decide which column contains the data of teh image).
Here below the XML code of an image that reads the
base64
value from a column: