Stretching text fields to accommodate data

By default, <textField> elements have a fixed size. If the data they need to display does not fit in their defined size, it is simply not displayed in the report. This is rarely the behavior we would want. Luckily, JasperReports allows us to alter this default behavior. This is accomplished by setting the isStretchWithOverflow attribute of the <textField> element to true.

The following JRXML template demonstrates how to allow text fields to stretch so that they can accommodate large amounts of data:

<?xml version="1.0" encoding="UTF-8" ?> <jasperReportxmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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.