Dynamic positioning of a object using X and Y coordinates

0

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

 

 

 

lpruthveraaj's picture
Joined: Mar 25 2016 - 2:23am
Last seen: 3 years 1 month ago

Could you please share the sample Code. How write java program  and how did you mapped java code on Jasper reports ?

lpruthveraaj - 3 years 4 months ago

3 Answers:

1

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)

hozawa's picture
52592
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 1 week ago
0

Could you please share the sample Code. How write java program  and how did you mapped java code on Jasper reports ?

 

lpruthveraaj's picture
Joined: Mar 25 2016 - 2:23am
Last seen: 3 years 1 month ago
0

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

mastermind11's picture
Joined: Nov 17 2013 - 8:12pm
Last seen: 2 years 11 months ago
Feedback