justsayr Posted July 21, 2017 Share Posted July 21, 2017 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 More sharing options...
Solution justsayr Posted July 24, 2017 Author Solution Share Posted July 24, 2017 <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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now