Setting text properties

JasperReports provides several ways to control text properties in the report. We can control the font, whether the text is bold, italic, underlined, its background and foreground colors, and so on.

Styles

One way JasperReports allows us to control text properties is by using the <style> element. This element allows us to control the foreground and background colors, the style of font (bold, italic, or normal), the font size, a border for the font, and many other attributes. Styles can extend other styles and add to or override properties of the parent style.

The following JRXML template illustrates the use of styles:

<?xml version="1.0" encoding="UTF-8" ?> <jasperReport name="ReportStylesDemo" xmlns="http://jasperreports.sourceforge.net/jasperreports" ...

Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.