Is there any way to acheive the dynamic positioning of any object like (Rectangle, Image, Line, Text Box.) to move them at exact position based on the logic of X and Y?
Could you please tell us, if there is any way to achieve this ?
Thanks & Regards,
This is doable though not straight forward.
I had a similar requirement and solved it as following:
From JasperPrint object, get pages (it's a list of pages, for now considering just 1 page). From each page fetch all elements on a page and change any attribute, including X and Y coordinates.
Example code (considering just 1 page):
List page = jasperPrint.getPages().get(0);
List pageElements = page.getElements();
pageElements.get(0).setX(30); // set x=30 for first element on page 1
Now you can work on these pageElements to set dynamic coordinates or change other attributes like height, width, etc.
After manipulating the jasperPrint object you can export to PDF or other formats.
If anyone is wondering how to get JasperPrint object, it is returned by
JasperPrint jasperPrint = JasperFillManager.fillReport(...)