Referencing images using the REST XHTML Exporter

Hello community,

 

I have a report with a logo in it (jpg). When I call the report using the rest_v2/reports service and use PDF as export format, the logo image gets rendered. If I use HTML though, I only get a broken image icon.

My image expression is "repo:/Reports/MyLogo.jpg" where "Reports" is the folder name where both my reports and the image are.

I call my report using

https://<<myJasperHost>>/jasperserver-pro/rest_v2/reports/Reports/<<myReport>>.html

and

https://<<myJasperHost>>/jasperserver-pro/rest_v2/reports/Reports/<<myReport>>.pdf

respectively.

My image expressin class is String, but I already tried the others and also all possible options on the image element.

How can I reference the image - do I need another REST call (and how would it look like)?

 

Thanks & Cheers,

Peter

 

peter_tonev's picture
Joined: Jun 24 2013 - 4:45am
Last seen: 9 years 10 months ago

2 Answers:

Hi there,

 

I now found a workaround myself - a "real" solution though would be better.

The workaround is to deploy the image e.g. on a web server within your domain (though this isn't a must have) and point to it using lazy evaluation.

 

Cheers,

Peter

peter_tonev's picture
Joined: Jun 24 2013 - 4:45am
Last seen: 9 years 10 months ago

Hi,

Can we see the image tag in your JRXML? Do you set it isLazy=true when the image expression points to "repo:"?

Thanks,
Teodor

teodord's picture
53258
Joined: Jun 30 2006 - 9:00am
Last seen: 11 hours 39 min ago

Hi Teodor,

the image tag (which works with the PDF exporter) is:

<image>
<reportElement uuid="ad03e624-3b65-4b9a-bc3c-6147b2ab49e1" x="0" y="0" width="154" height="65"/>
<imageExpression><![CDATA["repo:/Reports/MyLogo.jpg"]]></imageExpression>
</image>

It doesn't work with the XHTML exporter.
I'm not sure though whether I simply don't use here the proper image embedding settings or if we possibly have some issue with our application configuration, so the XHTML exporter cannot export the image together with the report.

The workaround which functions with XHTML was to deploy the image on a web server within our domain (relative path to it being /styles/img/reports/), then my JRXML image tag looks like:

<image scaleImage="RetainShape" isLazy="true" onErrorType="Blank">
<reportElement uuid="ad03e624-3b65-4b9a-bc3c-6147b2ab49e1" x="0" y="0" width="154" height="65"/>
<imageExpression><![CDATA["/styles/img/reports/MyLogo.jpg"]]></imageExpression>
</image>

Thanx,
Peter

peter_tonev - 9 years 11 months ago
Feedback
randomness