RichText is element for displaying simple formatted text in your reports. The key property of TextField object is Text, which contains HTML text content that will be rendered and displayed by report engine. While regular TextField always displays text in single style, RichText field has the ability to switch rendering style by means of HTML tags.
At this moment, the following HTML tags are supported :
RichText data may consist of simple text, parameters or a combination of those. Empty strings are regular values, too.
Some <b>formatted</b> <font face=Verdana size=14pt color=0000ff></i>text</i></font> <div align=right>This text is aligned to the right </div> <div align=center>This text is centered,<br> and broken in two lines </div>
RichText has a number of properties for display adjustment. Most of them are self-explanatory, and the full list is given bellow. Yet, one property is a little complicated and deserves deeper insight. OverflowTextHandling defines the manner how overflown text is processed (the situation when given text is long and does not fit into field area). If set to Ignore, overflown text is never shown, and the only visible text is one that fits into field area ; RichText has the same content over the parent section. However, if set to Display, whole text is shown in the following pages of the report, ie. this value could produce multiple pages within section. Set OverflowTextHandling=Display for long text chunks which spread over more then one page.
Beside static text, RichText can display dynamic data. Using parameters in RichText is explained in detail in chapter Parameters.
Assume you have report containing RichText with Name set to "field0". All you should do is set report XML file, then set the text content to show.
// C# code
Stampa.ReportDocument document = new Stampa.ReportDocument();
// set .xml file for printing
document.setXML("richtext.xml");
// add text content to TextField
document.AddRichText("field0", "Dynamic <i>formatted</i> <b>text</b>");
Sample XML structure for RichText element :
<richTextField name="field1" x="94" y="169" width="180" height="30" horAlignment="None" verAlignment="None"
Layout="EveryPage" Selectable="True">
<data>
<![CDATA[Some <b>formatted</b> <font color=ff000><i>text</i></font>]]>
</data>
<font family="Tahoma" size="10" underline="False" />
<textPadding value="2" />
<overflowTextDisplay value="False" />
<foregroundColor color="Black" />
<backgroundColor color="White" />
<border width="1" color="Black" />
</textField>
| BackgroundColor | Back color of the text area. Default value : Transparent |
| BorderColor | Border color of the text area. Default value : Black |
| BorderWidth | Border width of the field (in pixels). If set to 0, border is not drawn. Default value : 1 |
| Font | Display font for text data. Default value : Tahoma, 10pt, Regular |
| ForegroundColor | Color for text data. Default value : Black |
| Height | Field area rectangle height (in pixels). Due to the font drawing issues, height should be few pixels greater then text line height (ie. font height) |
| HorizontalAlignment | TextField alignment within page, relative to margins. Default value : None |
| Layout | This property defines if element is displayed on every section page, first or last page only. Valid values are : EveryPage, FirstPage, LastPage. Note : if this property is set to FirstPage or LastPage, text field property OverflowTextHandling is always considered as Ignore! Default value : EveryPage |
| Name | The name of the TextField element. |
| OverflowTextHandling | OverflowTextHandling defines the manner how overflown text is processed (the situation when given text is long and does not fit into field area). If set to Ignore, overflown text is never shown, and the only visible text is one that fits into field area ; RichText has the same content over the parent section. However, if set to Display, whole text is shown in the following pages of the report, ie. this value could produce multiple pages within section. Set OverflowTextHandling=Display for long text chunks which spread over more then one page. |
| Padding | Inner padding of the field. The distance in pixels from the text to field border. Default value : 2 |
| Selectable | This property defines whether object can be selected by left mouse click in design mode. Useful for locking background objects during design mode. If set to false, object can only be selected through Object Browser. Default value : true |
| Text | Text data for display. See general notes for TextField object. |
| VerticalAlignment | RichText vertical alignment within page, relative to margins. Default value : None |
| Width | RichText width (in pixels). |
| X | Left border coordinate (in pixels). |
| Y | Top border coordinate (in pixels). |