Jump to content
Changes to the Jaspersoft community edition download ×

Set the scaleImage property dynamically according to the size of the image


justsayr
Go to solution Solved by justsayr,

Recommended Posts

 scaleImage="RetainShape"  works correctly for a larger image but for a smaller image, it enlarges(stretches, hampering the image quality) it as per either by width or height of the report element .

 

 

<image scaleImage="RetainShape" hAlign="Center" vAlign="Middle">

<reportElement x="10" y="10" width="534" height="300" uuid="d813ec39-6f47-4361-9d82-c312924c2ba0"/>

<imageExpression><![CDATA[$P{originalImage}]]></imageExpression>

</image>

 

Can we set the scaleImage property Dynamically? if (image is large)  scaleImage="RetainShape"  else scaleImage="Clip"

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution
<style name="scaleImageStyle" hImageAlign="Center" vImageAlign="Middle">    <conditionalStyle>        <conditionExpression><![CDATA[$P{originalImage}.getHeight(null) <=300]]></conditionExpression>        <style scaleImage="Clip"/>    </conditionalStyle>    <conditionalStyle>        <conditionExpression><![CDATA[$P{originalImage}.getHeight(null) >300]]></conditionExpression>        <style scaleImage="RetainShape"/>    </conditionalStyle></style>[/code]
<image hAlign="Center" vAlign="Middle">            <reportElement style="scaleImageStyle" isPrintRepeatedValues="false" x="0" y="0" width="535" height="300" uuid="d813ec39-6f47-4361-9d82-c312924c2ba0"/>            <imageExpression><![CDATA[$P{originalImage}]]></imageExpression>        </image>[/code]

Well, I got some help on Stackoverflow and achieved it  by creating  a conditional style and applying it to the image taghttp://community.jaspersoft.com/sites/all/libraries/ckeditor/plugins/smiley/images/lightbulb.gif

Link to comment
Share on other sites

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...