Automatic line breaking with images

0

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.

 

 

toffer's picture
36
Joined: Oct 21 2013 - 2:43am
Last seen: 4 years 1 month ago

I would start by looking at

        JRPrintText()

        net.sf.jasperreports.engine.JRPrintElement

This may lead to some help.

Java_Jasper - 7 years 5 months ago
show 1 more...

@Java_Jasper: Thanks, but I think this cannot be applied to my issue, as I want to handle the layout of images and not text

toffer - 7 years 5 months ago

2 Answers:

1

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

Best regards,
Massimo.

 

mrabbi's picture
11528
Joined: Oct 31 2011 - 9:20am
Last seen: 2 weeks 3 days ago

Thanks Massimo. But when I split the images into two frames with horizontal layout, they cannot swap from one to the other, as stated in my above example (i.e. move image #4 from the lower frame to the upper one, when #3 has printWhenExpression set to false).

toffer - 7 years 5 months ago

Sorry in a rush I wrongly wrote printWhenExpression. I think you should manage the "Image Expression" in a custom way instead. This way you will have always the grid 2x3, but you will print the correct image in the block depending on the specific condition. Therefore it will happen that in specific cases you will have the last image expression empty/null.

mrabbi - 7 years 5 months ago
0

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.

toffer's picture
36
Joined: Oct 21 2013 - 2:43am
Last seen: 4 years 1 month ago
Feedback