Report text color

Aug 15, 2013 at 9:34 AM
I need to export a report and be able to change the color of some words. I've noticed that the Paragraph style is used when the report is actually being written, so I can't change it to the desired color, and then switch back to the default (black) because all will be written in black.

I've tried to convert HeaderStyles to a list instead of an array but that gave me a lot of troubles and finally a rare exception occurred. After that I just tried to increase HeaderStyles array to 25 (I will need 20 different colors + let intact the 5 default header style).

The problem is that if I set the array bigger than 9 a null reference exception occurs. I wonder if there is a better way of implementing this requirement and if not what can I do for being able to increase the array size of HeaderStyles to 25.

inside a loop:
  ParagraphStyle myStyle = new ParagraphStyle { BasedOn = reportStyle.DefaultStyle };
                               reportStyle.HeaderStyles[4 + myStyleSelector ] = myStyle ;
                              report.AddHeader(5 + myStyleSelector , "my text");
   using (var w = new PdfReportWriter((dlg.FileName)))
                           w.WriteReport(report, reportStyle);
Aug 15, 2013 at 3:05 PM
HeaderStyles should only be used for headers. We could change the array to a list, but normally 5 or 6 (html limit) should be enough.
To change the color on parts of a paragraph, we need to implement Inline elements with a Style property. I have added an issue: