Jump to content
We've recently updated our Privacy Statement, available here ×

Automatic line breaking with images


toffer

Recommended Posts

Let's say I got six images in a grid of 3x2:
tableOfContents.png.eb797221a14566689780caf62676e5cd.png

 

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:
tableOfContents_oneNotPrinted.png.8ef4f121c79940dd905aa7fecc51e485.png

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.

 

 

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

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.

 

Link to comment
Share on other sites

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).
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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