Jump to content
Changes to the Jaspersoft community edition download ×

Problem In ReportFont


ktrinad

Recommended Posts

By: Preethi N - preethin

Problem In ReportFont

2004-03-22 03:59

Hello,

I am creating the jasperreport programmatically

I have defined 3 or 4 reportFonts. But when I use the any of these reportFonts, it is using the normalFont.I mean to say that eventhough the reportFont size if 12 and isBold, still it prints with the normal size and without Bold.

 

Here is the code.

 

These are the reportFonts :

JRDesignReportFont normalFont = new JRDesignReportFont();

normalFont.setName("Arial_Normal");

normalFont.setDefault(false);

normalFont.setFontName("Arial");

normalFont.setSize(8);

normalFont.setPdfFontName("Helvetica");

normalFont.setPdfEncoding("Cp1252");

normalFont.setPdfEmbedded(false);

jasperDesign.addFont(normalFont);

 

JRDesignReportFont boldFont = new JRDesignReportFont();

boldFont.setName("Arial_Bold");

boldFont.setDefault(false);

boldFont.setFontName("Arial");

boldFont.setSize(8);

boldFont.setBold(true);

boldFont.setPdfFontName("Helvetica-Bold");

boldFont.setPdfEncoding("Cp1252");

boldFont.setPdfEmbedded(false);

jasperDesign.addFont(boldFont);

 

JRDesignReportFont bigBoldFont = new JRDesignReportFont();

boldFont.setName("Arial_Big_Bold");

boldFont.setDefault(false);

boldFont.setFontName("Arial");

boldFont.setSize(12);

boldFont.setBold(true);

boldFont.setPdfFontName("Helvetica-Bold");

boldFont.setPdfEncoding("Cp1252");

boldFont.setPdfEmbedded(false);

jasperDesign.addFont(bigBoldFont);

 

JRDesignReportFont italicFont = new JRDesignReportFont();

italicFont.setName("Arial_Big_Normal");

italicFont.setDefault(false);

italicFont.setFontName("Arial");

italicFont.setSize(10);

italicFont.setBold(false);

italicFont.setPdfFontName("Helvetica");

italicFont.setPdfEncoding("Cp1252");

italicFont.setPdfEmbedded(false);

jasperDesign.addFont(italicFont);

 

This is how I use it -

 

JRDesignTextField textField = new JRDesignTextField();

textField.setX(0);

textField.setY(0);

textField.setWidth(500);

textField.setHeight(15);

textField.setTextAlignment(JRTextElement.TEXT_ALIGN_CENTER);

textField.setFont(bigBoldFont);

JRDesignExpression expression = new JRDesignExpression();

expression = new JRDesignExpression();

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

expression.setText("$P{printtexthandler}.getValue("report_title_1")");

textField.setExpression(expression);

band.addElement(textField);

 

textField = new JRDesignTextField();

textField.setX(0);

textField.setY(15);

textField.setWidth(500);

textField.setHeight(15);

textField.setTextAlignment(JRTextElement.TEXT_ALIGN_CENTER);

textField.setFont(bigBoldFont);

expression = new JRDesignExpression();

expression = new JRDesignExpression();

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

expression.setText("$P{printtexthandler}.getValue("report_title_2")");

textField.setExpression(expression);

band.addElement(textField);

 

Where did I go wrong?Plz help me out.

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