Jump to content
JasperReports Library 7.0 is now available ×

Add a rectangle to the JasperPrint


2004 IR Help

Recommended Posts

By: joã¯esteves - jrfe

Add a rectangle to the JasperPrint

2005-07-29 06:22

Hi there!

 

My goal is to design a rectangle on a JasperPrint.So far i managed to do things like this example:

 

JRPrintPage page1 = (JRPrintPage)jasperPrint.getPages().get(0);

JRPrintElement elem =

(JRPrintElement)page1.getElements().get(0);

elem.setX(30);

 

The result is that the first element of the first page of the report, will be relocated at X = 30 . This works.

 

However i need to add new rectangles do the report, and i haven't found a way to do so. If anyone out there could help me i would certainly appreciate it.

 

 

 

 

By: alanHardwick - alan314

RE: Add a rectangle to the JasperPrint

2005-07-29 07:10

Yep!! Have done something similar:-

 

i.e. Define a method like the below where you pass your JRPrintPage object and the rectangle dimensions:-

 

private static JRPrintPage jrRectangle(JRPrintPage page, int left, int top, int height, int width) {

JRPrintRectangle rect = new JRBasePrintRectangle();

rect.setPen(JRLine.PEN_THIN);

rect.setX(left);

rect.setY(top);

rect.setWidth(width);

rect.setHeight(height);

page.addElement(rect);

return page;

}

 

and whenever you want a new rectangle, you can call

it by:

 

e.g.

 

jrRectangle(page1, PAGE_MARGIN_LEFT, PAGE_MARGIN_TOP + 665, 61, 535);

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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