Jump to content
JasperReports Library 7.0 is now available ×

Problem In ReportFont


2005 IR Help

Recommended Posts

By: Preethi N - preethin

Problem In ReportFont

2004-03-21 22:54

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.setReportFont("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.setReportFont("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.

 

 

 

 

By: David Lim - aberrant80

RE: Problem In ReportFont

2004-03-21 23:28

I don't really know for sure, but why did you call setReportFont for boldFont and bigBoldFont?

 

 

 

 

By: Preethi N - preethin

RE: Problem In ReportFont

2004-03-21 23:33

I gave setReportFont only when I found that the font was not properly working..I gave it simply.

You can ignore that. Do you have a idea as to where I went wrong

 

 

 

 

By: David Lim - aberrant80

RE: Problem In ReportFont

2004-03-22 00:24

I have no idea actually. It looks exactly like the sample. Maybe you could try to set one of them to default. You did add the band to the JasperDesign rite? What format are out generating the report to? Also, what version of JasperReports? I can't help, but more info might let others help.

 

 

 

 

By: Preethi N - preethin

RE: Problem In ReportFont

2004-03-22 01:11

Actually I am generating a PDF report using this. I am adding everything to the band as in the PDF file these are being printed but using normalFont.Even making one of as default doesn't work.

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