Hitachi Vantara Pentaho Community Forums
Results 1 to 11 of 11

Thread: using image-field in report designer to show images based on data

  1. #1

    Default using image-field in report designer to show images based on data

    I want to substitute data for images and documentation ive found suggests dragging the image-field tool onto the report. It says

    "To add dynamic images to your report, use the content-field report element . The content field accepts different types of image inputs for rendering. The first approach is dynamically changing the image location within your dataset. If you have a field that contains a URL or file system location to your image, the content-field element will render the specified image."

    Basically my data has values 'up' and 'down' and i want pictures of arrows instead of the words. From what i can tell, I should be able to amend my mysql query to replace 'up' and 'down' with urls of images? But this doesnt work...

    The query looks like:- if(a < b,'http://www.....up.jpg','http://www.....down.jpg') as arrows

    Then i dragged the image-field icon onto the report and changed the field value to 'arrows'

    When running the report, nothing shows under the arrows column. Anyone know what Im doing wrong?

  2. #2
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    As far as I can tell, this should have worked perfectly fine. Does your server require authentication of any kind? If so, make sure these images can be reached *without* any passwords, cookies or other magic.


    But there is no need to mess with your query. Use a formula on the "value" attribute instead:

    =IF ([a] < [b]; "http://localhost/up.jpg"; "http://localhost/down.jpg")

    Also make sure that your URL is readable - the engine does not abort the report processing if the images are not found, it just wont print them.
    If you want to be 100% sure, embed the images into your prpt file (File->Resources) and reference them by their embedded file-name. This also makes sure that you always take these images with you when you move the PRPT from your local workstation to the server.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  3. #3

    Default

    Thanks for the reply. Youre right, the server couldnt reach the urls but when i stored the jpgs on the bi server it worked fine. I tried to embed the images like you said but dont know how to reference them in the report, ie path. Could you tell me how to do that? As the problem I have storing the files on the server is when i publish the report it ceases to find the images...

  4. #4

    Default

    Thump, thump. Hate bringing up old threads. But how exactly does one "use" an embeed image. I got it all there File -> resources. But now what?

  5. #5
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Press "Import" and add your file. You have the file name (path to the image on your disk), entry-name (how the image will be known inside the report bundle) and the content type (should match your image type).

    Then, in a image-field, you can reference that file by the entry-name you just given.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  6. #6
    Join Date
    Jul 2010
    Posts
    16

    Default

    I have the same issue. My image url value is coming from DB. Based each client the image value is different and it is defined in DB. I am able to access the image directly via internet. I created image field and set filed attribute value to field from sql, but it is not doing anything. I appreciate your help.

  7. #7
    Join Date
    Jul 2010
    Posts
    16

    Default

    Never mind it is working fine. The blank space in image name causing problem. Removed the spaces in the name and they are working fine now.

  8. #8
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    @Murali1974: Urls of course must be properly URL encoded. Otherwise you end up sending garbage to the server and the server responds with a unhappy reply.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  9. #9
    Join Date
    Sep 2008
    Posts
    19

    Default

    EDIT: Found the answer myself - just add the image name to the content-field value element as a function. For example: ="myimage"

    Excuse my ignorance, but how do I subsequently reference the Resource filename in the image-field element?

    Quote Originally Posted by Taqua View Post
    Press "Import" and add your file. You have the file name (path to the image on your disk), entry-name (how the image will be known inside the report bundle) and the content type (should match your image type).

    Then, in a image-field, you can reference that file by the entry-name you just given.
    Last edited by andersdd; 12-11-2013 at 06:32 PM.

  10. #10

    Default

    Pictorial from anderssd's instructions.

    1. Add the image to the resources, first open the resource editor
    Name:  File_and_Menubar-2.jpg
Views: 1483
Size:  16.0 KB

    2. Import the resource.
    Name:  Resource_Editor_and_Pentaho_Report_Designer_-__Untitled_Report_-2.png
Views: 1432
Size:  23.6 KB

    Hint, use the [..] button to browse your folders

    Name:  Resource_Editor.png
Views: 1415
Size:  14.7 KB

    3. Drag an image-field element to the report
    Name:  Screenshot_12_13_13__12_25_AM-2.png
Views: 1422
Size:  4.4 KB

    4. Go to the value expression button on the attributes tab of the image-field that you just dropped.
    Name:  Pentaho_Report_Designer_-__Untitled_Report_-7.png
Views: 1442
Size:  15.8 KB

    5. Change the expression to a simple formula (However, you aren't limited to that, you can use real OpenFormula if you like)

    I named my resource genericpic, so in the expression I'll do ="genericpic"

    Run your report and you should see the image appear.

    Thanks to anderssd for the solution.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    I don't work for Pentaho, but I like their stuff.

    Justin Barrett
    This sig may be my last!

  11. #11
    Join Date
    Jul 2015
    Posts
    5

    Default

    Thank you for explaining with image.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.