Stretch a string to match the data in jasper reports using iReport

How to stretch a text field to match data, if the data exceeds the height of the strip, the text field does not stretch. I added a text field tag to my jrxml ...

Example:

<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
    <reportElement
                    style="dNew"
                    mode="Opaque"
                    x="200"
                    y="0"
                    width="200"
                    height="19"
                    key="value-2"
                    stretchType="RelativeToTallestObject"
                    positionType="Float"
                    isPrintInFirstWholeBand="true"
                    isPrintWhenDetailOverflows="true"/>
    <box></box>
    <textElement textAlignment="Center" verticalAlignment="Top">
        <font fontName="Arial" pdfFontName="Helvetica"/>
    </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{DATA2}]]></textFieldExpression>
</textField>
+3
source share
1 answer

Some groups are not stretched, but if you are talking about a group of parts, you can do something like this:

<textField isStretchWithOverflow="true" isBlankWhenNull="true">
    <reportElement style="base" positionType="Float" 
       isPrintRepeatedValues="false" x="0" y="3" 
       width="380" height="26" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression class="java.lang.String">
       <![CDATA[$P{information}]]></textFieldExpression>
</textField>

This is pasted from automatically generated XML, so there are a lot of superfluous things, but isStretchWithOverflow = "true" should work for you. This will make the field stretched when the text fills it.

iReport , . XML.

+3

Source: https://habr.com/ru/post/1714116/


All Articles