How to programatically set alternate image in report if image does not exist in path



  • Hi sir,

    I have a report i want to programmatically (before render script) set src path of image using before render script. But couldn't find any example. could please show me one example?

    Also i have few doubts,

    • How to display dynamic image using a path in jsreport?

    • Also if image does not exist in that path then display alternate image from different path?



  • Isn't it better to use templating engine helpers to set properly the src path?
    Please elaborate on why the beforeRender script is your choice.

    How to display dynamic image using a path in jsreport?

    Do you mean path to disk? Just like in HTML using file:/// URI.

    Also if image does not exist in that path then display alternate image from diffrent path?

    That requires just some coding on your side. Check if the file exists using nodejs fs module and set a different path when it doesn't.



  • My requirement is, we have global reports which stored in aws s3.Intially logo is coming from a predefined path (global path). In our application user can clone those report so that report will stored in aws s3 against client folder.Then user can change logo by upload different logo and new logo will be stored in client folder .

    So path of the logo will be dynamic that is why i choose before render script, where i can check if image does not exist in client path then i can show image from global path while user try to print the report. Could please reply with an example to display image from a path using before render script? Also could you please suggest any idea?

    Also you told me that ,It is better to use templating engine helpers to set properly the src path. i dont understand what do you mean by this .please show me one example?


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.