Thomas_J Posted January 28, 2013 Share Posted January 28, 2013 Hi, I'm attemping to build a PHP client that displays HTML reports. My reports looks fine when they are exported to PDF, for example. Only when displaying the report in HTML format in the browser, the images are missing. I am using the PHP client provided on this site to fetch the report: $FullReport = $client->runReport($uri, 'html', null, $controls); I then dump out $FullReport to my browser, which produces the above issue. I noticed that the HTML references relative paths, so I have tried to point directly to the JasperServer resources, without any luck: $patterns = array(); $patterns[] = '/src='/'; $patterns[] = '/src="/'; $replacements = array(); $replacements[] = 'src='http://address:port'; $replacements[] = 'src="http://address:port'; $FullReport = preg_replace($patterns, $replacements, $FullReport); I also found that when I login in the browser directly, and then invoke the report, the images will show (because it fetches the images directly from the JasperServer, bypassing my Tomcat server): http://address:port/jasperserver/rest/login?j_username=jasperadmin&j_password=jasperadmin http://address:port/jasperserver/rest_v2/reports/reports/Sample/SearchStockReport.html?ItemCodeFilter=&ItemNameFilter= Moreover, when I do this within the same browser window, my above workaround does work! But it all depends on having logged in in the same browser window first. Can anyone provide any idea on how I can progress with this issue? Thanks Link to comment Share on other sites More sharing options...
Thomas_J Posted February 4, 2013 Author Share Posted February 4, 2013 I was hoping a more sophisticated solution would dawn, but alas, hopefully the following is of use to anyone in the future:I have now resolved this issue by moving the image directly to my web server, rather than embedding it in the report. In the iReport Designer I have set the ImageExpression property to point directly to this image (the image location surrounded with double quotes) and I have set the Is Lazy property to true to ensure that the image on my web server is referenced when the report is executed.I'm still a little worried that I have to go back and manually edit all my reports if my host address should change in the future, so if anyone can drop some hints on whether or not this can be made configurable, that would be much appreciated. Otherwise this solution works like a charm. Link to comment Share on other sites More sharing options...
grantbacon Posted March 3, 2013 Share Posted March 3, 2013 Along with your inputControls, try adding:$controls['attachmentsPrefix'] = 'http://url.to.report.attachments/prefix/';This should prefix any attachment within the HTML of the report with the URL provided, so the data isnt' being pulled from the report server but from a webserver. I haven't tested this though, so let me know how it goes Link to comment Share on other sites More sharing options...
ybaudrusepta.org Posted May 24, 2013 Share Posted May 24, 2013 Hi Thomas, looking around sound that it is the only solution.... Do you mind posting your code to get the image from your jasper server to your webserver. I am able to do it with SOAP but not rest... many thx ... Link to comment Share on other sites More sharing options...
grantbacon Posted July 30, 2013 Share Posted July 30, 2013 You do have to host the files currently on a separate web server... soon in the future I believe there will be support to request attachments individually and build them into the report Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now