This recipe teaches you how to handle the presentation of dynamic data in text fields, which can contain large amounts of data. Large dynamic text scenarios occur when your report contains sentences, the exact word count of which is not known while designing a report and will be determined during report processing (for example, a sentence that contains the name and address of a company). In such situations, the large text size can overflow the size of the field and, therefore, wrapping to the next line may become essential.
Refer to the installPostgreSQL.txt
file included in the source code download for this chapter to install and run PostgreSQL, which should be up and running before you proceed. The source code for this chapter also includes a file named copySampleDataIntoPGS.txt
, which helps you create a database named jasperdb3
and copy sample data for this recipe into the database.
VerticalStretch.jrxml
file from the Task4
folder in the source code for this chapter. The Designer tab of iReport shows a report, as follows:<font>
tag at the beginning of the expression. size
parameter of the<font>
tag from 13
to 25
. Click on the Apply button. The Expression editor will disappear.This recipe works because JasperReports allows us to use stretchable fields, which it automatically stretches in a vertical fashion when it sees that data in the field cannot be accommodated within one line. If you switch to the XML tab, you will see the following JRXML code for the text field that you made stretchable in this recipe:
<textField isStretchWithOverflow="true">
You can see the isStretchWithOverflow="true"
attribute in the<textField>
tag. This attribute makes your text fields stretchable. iReport authored this attribute in response to step 9 of this recipe.
3.135.204.0