How to set left and width property of subreport dynamically using ireport 5.1

0

I have a main report and two sub report which contains one cross tab in each. I want to set width and left property of both sub report in detail band dynamically which I will pass as a param to main report. In between both sub report there is a gap, how to remove it? Cross tab has dynamic no of columns. I can calculate the width of both sub report and set main report page width(total of both sub report) as per that calculated value and also pass those as param. Any help is appreciated. I have tried to set pageWidth and Left/Width property from param but that's not working.

mousumib's picture
Joined: Nov 25 2019 - 2:48am
Last seen: 3 days 16 hours ago

1 Answer:

0

Get idea from following post and done it.

https://community.jaspersoft.com/questions/1013551/dynamic-positioning-object-using-x-and-y-coordinates

Code snippet :

jasperPrint.setPageWidth(pageWidth);
JRPrintPage page = jasperPrint.getPages().get(0);
List<JRPrintElement> pageElements = page.getElements();
pageElements.get(3).setX(0);  
pageElements.get(3).setWidth(tab1Width);
pageElements.get(5).setX(tab1Width);  

pageElements.get(6).setX(tab1Width+tab2Width+10); 
pageElements.get(7).setX(tab1Width+tab2Width+90); 

mousumib's picture
Joined: Nov 25 2019 - 2:48am
Last seen: 3 days 16 hours ago
Feedback
randomness