Jump to content
Changes to the Jaspersoft community edition download ×

Dynamic positioning of a object using X and Y coordinates


lpruthveraaj

Recommended Posts

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

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

  • 5 months later...

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

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