cancel
Showing results for 
Search instead for 
Did you mean: 

Set Font and Size of all Report Text before extraction

0 Kudos

Dear all,

I've a problem with Calibri font that I couldn't face off in the new server.
The most safety (but not the most beauty) solution is to convert all the .rpt in a copy with Arial Font instead Calibri one.

However, we have A LOT of report and this is a huge work to be done.
I would ask you so if there is a quickly way to set Font and Size of all character in a report before extraction, when it is called by a .NET procedure.

Cordially,

Trezzi Alessandro

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

As I posted in the other thread, there is a way to do this in C#. Load the report into a ReportDocument object and then do the following:

Font regularFont = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
Font headerFont = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);
foreach (Section section in procRpt.ReportDefinition.Sections)
{
  foreach(ReportObject rptObj in section.ReportObjects)  
  {
    switch (rptObj.Kind)
    {
      case ReportObjectKind.FieldObject:
        FieldObject fldObj = (FieldObject) rptObj;
        fldObj.ApplyFont(regularFont);
        break;
      case ReportObjectKind.FieldHeadingObject:
        FieldHeadingObject fhObj = (FieldHeadingObject) rptObj;
        fhObj.ApplyFont(headerFont);
        break;
      default:
        break;
    }
  }
}


I didn't find a way to update the objects in a CrossTab, so you may have to manually update any reports that use them.

-Dell

0 Kudos

Thank's a lot Stinnet,

The logic of this piece of code is, if I've understood, that you're setting Bold style in header and regular style in other fields?
There is no way to set a Font variable without the third input, the FontStyle? In this way I'm expecting that all words that is Bold in a FieldObject will become Regular.

DellSC
Active Contributor
0 Kudos

Yes, you can take the FontStyle parameter out and just put the FontFamily and Size.

-Dell

0 Kudos

So if I define a variable like this it should work?
Font regularFont =new Font(FontFamily.GenericSansSerif,10)
or FontStyle has to be set in some way as a defalut parameter?
And if it is, how?

DellSC
Active Contributor
0 Kudos

I'm not sure as I've not actually used this code. I'd play with it in a sample report and see what it takes to do what you need to do.

-Dell

Answers (0)