Jump to content
Changes to the Jaspersoft community edition download ×

HTML Report REST v2 not showing images


Thomas_J

Recommended Posts

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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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

  • 4 weeks later...

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

  • 2 months later...
  • 2 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...