print image base64 in birt report

azhar3001
edited February 11, 2022 in Analytics #1
Hi All,

I have a question.
I want to display an image base64 from database in BIRT REPORT.
but, I have no idea how to do it.
Can anybody help me, how I can do this?


currently I using birt 2.6


thanks

Comments

  • kclark
    kclark E
    edited December 31, 1969 #2
    <a class='bbc_url' href='http://www.birt-exchange.org/org/devshare/designing-birt-reports/1377-inline-base64-image-in-html-output/'>Take a look at this devshare</a>. It shows how to encode an image as base64 then display it. Since it sounds like you've already got the image stored in your db as base64 you should be able to skip the encoding and use the second part of the script to display the image.
    Warning No formatter is installed for the format ipb
  • azhar3001
    edited December 31, 1969 #3
    thanks for your reply

    I not understand for that code

    var myurl = URL("http://tomcat.apache.org/images/tomcat.gif");
    var img = ImageIO.read(myurl);
    bas = new ByteArrayOutputStream();
    ImageIO.write(img, "gif", bas);
    bas.flush();

    encodedimga = Base64.encodeBase64(bas.toByteArray());
    encodedimg = new String( encodedimga, "utf-8");
    bas.close();
    imgsrc = "data:image/gif;base64,"+encodedimg+"\"";



    the first 1, it encode the image to binary.
    but, i already have 64binary code...
    so, can skip it

    but the second one, what the value for bas?
    i try replace it as
    this.getRowData().getColumnValue("B_CONTENT") // b_content is my column
    but can't work
  • azhar3001
    edited December 31, 1969 #4
    nevermind,

    I have a solution about that
    just use the text only..

    <value-of format="HTML">
    if(row["B_CONTENT"] == null) {"";}else{
    "<img src='data:image/png;base64,"}</value-of><value-of format="HTML"> row["B_CONTENT"]</value-of><value-of format="HTML">
    if(row["B_CONTENT"] == null ) {"";}else{"' height='120' width='100' />"}

    </value-of>



    tq
  • Edward_ha92
    edited January 31, 2019 #5

    I'm new in BIRT using and i would like to ask you ,Where should i write this text ?

    @azhar3001 said:
    nevermind,

    I have a solution about that
    just use the text only..


    if(row["B_CONTENT"] == null) {"";}else{
    "image row["B_CONTENT"]
    if(row["B_CONTENT"] == null ) {"";}else{"' height='120' width='100' />"}

  • I am not familiar with this example, but the tags typically are entered in a Text element. Add a Text element from the Palette to a table cell, change its type to "HTML" in the editor, and enter the code. The JavaScript will run as normal and the data (i.e. row["B_CONTENT"]) will automatically be filled in with the data value for the column specified for each row that is generated.

    Warning No formatter is installed for the format ipb