Automatic line breaking with images
Posted on November 15, 2013 at 3:46am
Let's say I got six images in a grid of 3x2:
Now I would like to make the third image disappear by setting "printWhenExpression" to false and automatically let the fourth image take in the place of the third and the fifth of the fourth and so on:
What layout type or settings do I need to use to achieve this in a Jasper Report .jrxml? Either Free/Vertical/Horizontal Layout did not work out for me.
Posted on November 18, 2013 at 3:57am
the Free/Vertical/Horizontal layouts that you can set from Jaspersoft Studio is a feature of the report editor itself and not something that is related to the JasperReports Library.
If you try to look at JRXML level you will see something like this inside a container (i.e: band):
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
It's Jaspersoft Studio that detecting this kind of information will provide to arrange the elements and resize them, when they are dragged or moved inside the container. The idea is to create in the future more complex layout and provide framework / api in order to allow the user to do so. But for now these are the simple ones that you can use.
As far as I understood I think you should handle the showing of the images using the printWhenExpression in more images.
Of course you can obtain the 2x3 grid using a Vertical Layout in the band and putting two frames. Then on each frame use the Horizontal layout with three images each.
Posted on November 18, 2013 at 6:18am
I thought of an attempt to use some kind of counter variable that goes up, every time an image is printed and then use this to calculate the position of the next image. But unfortunately it seems, that dynamic values or expressions cannot be used as x/y position values...
Is there a way to maybe achieve this programatically in Java? Sorry, but I am still new to Jasper Reports.