How to run report on ireport which is running of Jasper Server with image paths?

941 views Asked by At

I am using Jasper Server version 6.0.1 and iReport version 5.6.0. I have an image on report it has path(Image Expression) according to server. When I run the report on iReport I does not find the path because it is path according to server. One option is I have to change path of every image according to local machine. If I use this option I have to change the path again before uploading to server. Is there any other option too?

1

There are 1 answers

2
Arasu On

Yes, you can pass the image path in parameter,

<parameter name="LOGO" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["/somePath/virgin.png"]]></defaultValueExpression>
    </parameter>
...
<image>
  <reportElement uuid="8a12495e-e2a9-4d0c-9e78-650a5c084fcd" x="0" y="1" width="100" height="66"/>
  <imageExpression><![CDATA[$P{LOGO}]]></imageExpression>
</image>

When you pass the image path from a java file that path will be used for loading the image. If you are not passing any value then default path will be used. Hope this helps.

UPDATE:

Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("LOGO", imageDirectory + "/myLogo.jpg");
JasperReport jasperReport = CompileManager.compileReport(jrxmlFilePath, mainReportName);
JasperPrint jasperPrint =
                    JasperFillManager.fillReport(jasperReport, parameters, null);

Have a look at here.