Java Reference
In-Depth Information
Setting Styles for Text Segments
The text property modification techniques described so far apply the text properties
to a complete text element. Sometimes we want to have certain segments of a text
element use a different style. For example, we might want to emphasize a word by
making it bold or italic . JasperReports allows us to do this by using styled text.
As we have seen in previous sections, the <textElement> and the <style> element
both contain an isStyledText attribute. We need to set this attribute to true to
use styled text. When this attribute is set to true , the text inside a <textField> or
<staticText> element is not interpreted as regular text, but as XML. The text to be
styled needs to be nested between <style> elements to obtain a different style from
the rest of the text. This style element contains similar attributes to before, but is not
the same as the <style> element discussed previously.
The following table lists all the attributes available to this <style> element:
Valid Values
Indicates what font to use for
the element.
A String indicating the font
to use.
Indicates the size of the font. An integer indicating the text
size to use.
Indicates whether the font
is bold.
true , false
Indicates whether the font
is italic.
true , false
Indicates whether the font
is underlined.
true , false
Indicates whether the font
is strikethrough style.
true , false
Indicates the name of the font
to use if the report is exported
to PDF.
Courier , Courier-Bold ,
Courier-BoldOblique ,
Courier-Oblique ,
Helvetica , Helvetica
Bold , Helvetica
BoldOblique , Helvetica
Oblique , Symbol , Times-
Roman , Times-Bold ,
Times-BoldItalic ,
Times-Italic ,
Indicates the encoding to
use if the report is exported
to PDF.
A String indicating the
encoding to use when the
report is exported to PDF.
Search WWH ::

Custom Search