Jump to content
Changes to the Jaspersoft community edition download ×

Label design problem


Recommended Posts

By: Enrico Goosen - enricogoosen

Label design problem

2003-09-12 05:59

I've created a Jasper Design to print address labels.

My design caters for 16 labels per page (2 columns).

My problem is that when I run the application and view my labels in JasperViewer, I only get 15 labels on the page. One gets carried over to the next page, even though there is space for one more label on that page.

 

Here's my code:

public JasperDesign getJasperDesign() throws JRException{

//JasperDesign

JasperDesign jasperDesign = new JasperDesign();

jasperDesign.setName("AddressLabelDesign");

jasperDesign.setPageWidth(595);

jasperDesign.setPageHeight(864);

jasperDesign.setColumnCount(2);

jasperDesign.setPrintOrder(JasperDesign.PRINT_ORDER_HORIZONTAL);

jasperDesign.setColumnWidth(265);

jasperDesign.setColumnSpacing(0);

jasperDesign.setLeftMargin(40);

jasperDesign.setRightMargin(25);

jasperDesign.setTopMargin(0);

jasperDesign.setBottomMargin(0);

 

//Fonts

JRDesignReportFont normalFont = new JRDesignReportFont();

normalFont.setName("Normal_Font");

normalFont.setDefault(true);

normalFont.setSize(13);

jasperDesign.addFont(normalFont);

 

//Fields

JRDesignField field = new JRDesignField();

field = new JRDesignField();

field.setName("firstnames");

field.setValueClass(java.lang.String.class);

jasperDesign.addField(field);

 

field = new JRDesignField();

field.setName("surname");

field.setValueClass(java.lang.String.class);

jasperDesign.addField(field);

 

field = new JRDesignField();

field.setName("address1");

field.setValueClass(java.lang.String.class);

jasperDesign.addField(field);

 

field = new JRDesignField();

field.setName("address2");

field.setValueClass(java.lang.String.class);

jasperDesign.addField(field);

 

field = new JRDesignField();

field.setName("city");

field.setValueClass(java.lang.String.class);

jasperDesign.addField(field);

 

field = new JRDesignField();

field.setName("postcode");

field.setValueClass(java.lang.String.class);

jasperDesign.addField(field);

 

//Detail

JRDesignBand band = new JRDesignBand();

band.setHeight(108);

 

JRDesignTextField textField = new JRDesignTextField();

textField.setX(10);

textField.setY(10);

textField.setWidth(265);

textField.setHeight(17);

textField.setFont(normalFont);

JRDesignExpression expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

expression.setText("$F{firstnames} + " " + $F{surname}");

textField.setExpression(expression);

band.addElement(textField);

 

textField = new JRDesignTextField();

textField.setBlankWhenNull(true);

textField.setX(10);

textField.setY(27);

textField.setWidth(265);

textField.setHeight(17);

textField.setFont(normalFont);

expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

expression.setText("$F{address1}");

textField.setExpression(expression);

band.addElement(textField);

 

textField = new JRDesignTextField();

textField.setBlankWhenNull(true);

textField.setX(10);

textField.setY(44);

textField.setWidth(265);

textField.setHeight(17);

textField.setFont(normalFont);

expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

expression.setText("$F{address2}");

textField.setExpression(expression);

band.addElement(textField);

 

textField = new JRDesignTextField();

textField.setBlankWhenNull(true);

textField.setX(10);

textField.setY(61);

textField.setWidth(265);

textField.setHeight(17);

textField.setFont(normalFont);

expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

expression.setText("$F{city}");

textField.setExpression(expression);

band.addElement(textField);

 

textField = new JRDesignTextField();

textField.setBlankWhenNull(true);

textField.setX(10);

textField.setY(78);

textField.setWidth(265);

textField.setHeight(17);

textField.setFont(normalFont);

expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

expression.setText("$F{postcode}");

textField.setExpression(expression);

band.addElement(textField);

 

JRDesignStaticText staticField = new JRDesignStaticText();

staticField.setX(10);

staticField.setY(95);

staticField.setWidth(265);

staticField.setHeight(13);

staticField.setFont(normalFont);

staticField.setText(" ");

band.addElement(staticField);

 

jasperDesign.setDetail(band);

 

//Column footer

band = new JRDesignBand();

jasperDesign.setColumnFooter(band);

 

//Page footer

band = new JRDesignBand();

jasperDesign.setPageFooter(band);

 

//Summary

band = new JRDesignBand();

jasperDesign.setSummary(band);

 

return jasperDesign;

}

 

 

 

 

By: Prem - premb007

2 column Label design

2003-12-11 09:21

Teodor,

 

Any suggestion for this.I too am facing the same problem. Is this a bug ??

 

In my case out of 20 labels only 11 are printed on page 1 & 9 on page 2, (no of column = 2)

 

 

 

 

By: Teodor Danciu - teodord

RE: 2 column Label design

2003-12-11 11:58

 

Hi,

 

If you use the horizontal filler, as Erico does,

then it is about this bug here:

 

https://sourceforge.net/tracker/index.php?func=detail&aid=816508&group_id=36382&atid=416703

 

It can be seen even in the "horizontal" sample and

it will be fixed in the next version.

I hope to make availabe the fix on the cvs before the

release.

 

Thank you,

Teodor

 

 

 

 

 

By: Teodor Danciu - teodord

RE: 2 column Label design

2003-12-11 13:31

 

Hi,

 

This is now fixed in the CVS version.

 

Thank you,

Teodor

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