HTML Report REST v2 not showing images



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):


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?


Thomas_J's picture
Joined: Jan 25 2013 - 7:57am
Last seen: 5 years 2 months ago

2 Answers:


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.

Thomas_J's picture
Joined: Jan 25 2013 - 7:57am
Last seen: 5 years 2 months ago

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 ... - 7 years 4 months ago

Along with your inputControls, try adding:

$controls['attachmentsPrefix'] = '';

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

grantbacon's picture
Joined: Oct 23 2012 - 1:10pm
Last seen: 2 years 3 months ago

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

grantbacon - 7 years 2 months ago