1
votes

I am using iReport. I want to know how to make an auto height rectangle?enter image description here

as per this sample image of detail band. There is two part one is data part on right side which fetch data and show. and left side part is a textarea data which is passed as parameter. I want to make both rectangle same height. It may possible that left side data height is bigger than right side part and vice versa. So I want to make both rectangle height same all the time.

For achieving this i use following code. where I don't use rectangles but a lines only

<columnHeader>
            <line>
            <reportElement x="0" y="28" width="555" height="1" uuid="9d2cb019-77f2-47a0-94f7-aa944b5c277e"/>
        </line>
    </band>
</columnHeader>

    <detail>
    <band height="13" splitType="Stretch">
        <textField>
            <reportElement x="472" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
            <textElement textAlignment="Right" verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
            <textElement verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
        </textField>
        <line>
            <reportElement x="471" y="0" width="1" height="13" uuid="434d1954-3286-4539-a3d9-915f28364210"/>
        </line>
        <line>
            <reportElement x="555" y="-1" width="1" height="13" uuid="39dab81d-1bb3-41bd-8fff-9780b7f65672"/>
        </line>
        <line>
            <reportElement x="0" y="-1" width="1" height="13" uuid="8936db56-872f-434d-a39b-298ffdb99e57"/>
        </line>
    </band>
</detail>
<summary>
    <band height="1" splitType="Stretch">
        <line>
            <reportElement x="0" y="-1" width="555" height="1" uuid="ba7dbcc7-fd20-4ee9-b593-480737f9b88c"/>
        </line>
    </band>
</summary>

But the issue with this way is corners of rectangle is not properly printed.

My questions are:

1) Is there any better way to do this?

2) how to draw a border of complete detail band?

3) How to do this with rectangle ?

Here is another try with rectangle around detail band but rectangle is repeated to each row.

<detail>
    <band height="13" splitType="Stretch">
        <rectangle>
            <reportElement stretchType="RelativeToTallestObject" x="1" y="0" width="552" height="13" uuid="80b946be-ac5f-495d-a507-fec3e22ea751"/>
        </rectangle>
        <textField>
            <reportElement x="465" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
            <textElement textAlignment="Right" verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
            <textElement verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
        </textField>
    </band>
</detail>
3

3 Answers

0
votes

Hello I think you can find the answer in their documentation in this Link: https://community.jaspersoft.com/wiki/dynamically-set-table-row-height-data

To sum up here are the options you should enable.

enter image description here

-1
votes

I think you should have one rectangle and place a line in between. Use the property of line, check stretchWithOverflow to true. Simillarly with rectangle.

-1
votes

First select your field and set following properties (third one is most important):

  1. Position type: float
  2. Stretch type: relative to tallest object
  3. Stretch with overflow: true (checked)