Skip to Content
0

Set Font and Size of all Report Text before extraction

Apr 13, 2017 at 03:10 PM

59

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Dell Stinnett-Christy Apr 13, 2017 at 03:26 PM
0

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded

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.

0

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

-Dell

0

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?

0

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

0