print image base64 in birt report

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

  • kclarkkclark BIRT Guru EM
    edited December 1969
    Take a look at this devshare. 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.

    Kristopher Clark

    Actuate Corporation – The BIRT Company™

    http://www.actuate.com | http://birtondemand.com

     

    My Blog

    Twitter

    LinkedIn
    Facebook
     

  • edited December 1969
    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
  • edited December 1969
    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
  • edited January 31

    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.

    Jeff F.
    Customer Support Engineer I
    OpenText
Sign In or Register to comment.