lpruthveraaj Posted July 5, 2016 Share Posted July 5, 2016 Hi , 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,Pruthvi Link to comment Share on other sites More sharing options...
hozawa Posted July 5, 2016 Share Posted July 5, 2016 Not with Jaspersoft Studio. It's possible if you program using JasperReports library. JasperReports maps jrxml to Java classes.I think what I did was get JRPrintPage.getElements() and just setX() on element fetched (e.g. JRBasePrintText) Link to comment Share on other sites More sharing options...
lpruthveraaj Posted July 5, 2016 Author Share Posted July 5, 2016 Could you please share the sample Code. How write java program and how did you mapped java code on Jasper reports ? Link to comment Share on other sites More sharing options...
lpruthveraaj Posted July 5, 2016 Author Share Posted July 5, 2016 Could you please share the sample Code. How write java program and how did you mapped java code on Jasper reports ? Link to comment Share on other sites More sharing options...
mastermind11 Posted December 13, 2016 Share Posted December 13, 2016 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 1Now 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 byJasperPrint jasperPrint = JasperFillManager.fillReport(...) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now