Dynamic text height in JasperReports

JasperReports is an open-source java library to build reports. It tightly integrates with the JFreeChart to provide charts.

For me, JasperReports is one of the best open source solutions I’ve ever used. It’s really customizable and configurable and you can do really fantastic things with it. While working for about a year with JasperReports, I’ve met several limitations and places which could be implemented better. So I plan to describe some solutions I’ve found here.

The first thing I’ve mentioned was the the fixed size of the elements specified in the report. For example you specify height for band and text element. But what if the text you need to display is out of the element dimensions? It’s truncated:

This problem can be easily solved by specifying isStretchWithOverflow attribute for the textEelement. At a minimum you’ll get the size specified by the height attribute. If the text content will be out of the element limits – it will be streched:

Please find all sources of the demonstration here