Layout 当文本字段溢出到新页面时,为什么会出现边框布局损坏?

Layout 当文本字段溢出到新页面时,为什么会出现边框布局损坏?,layout,jasper-reports,textfield,Layout,Jasper Reports,Textfield,我正在使用Jasper report打印PDF报告。当数据溢出并生成新页面时,我会发现边框布局损坏-右边框比左边框大一点(请看图片) 事实上,这真的很奇怪,我不明白我做错了什么 我的jrxml文件: <band height="70"> <staticText> <reportElement uuid="c5529319-8868-4c4f-a68c-36f6ce79d652" x="0" y="0" wid

我正在使用Jasper report打印PDF报告。当数据溢出并生成新页面时,我会发现边框布局损坏-右边框比左边框大一点(请看图片)

事实上,这真的很奇怪,我不明白我做错了什么

我的jrxml文件:

<band height="70">
            <staticText>
                <reportElement uuid="c5529319-8868-4c4f-a68c-36f6ce79d652" x="0" y="0" width="555" height="20" forecolor="#000000"/>
                <textElement textAlignment="Center" markup="none">
                    <font size="15" isBold="true"/>
                </textElement>
                <text><![CDATA[TEST DATA]]></text>
            </staticText>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement uuid="bcea9da4-49d2-498a-aefc-40ebfb747183" positionType="Float" stretchType="RelativeToTallestObject" x="216" y="50" width="339" height="20"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement>
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{title}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement uuid="91766db1-a506-4115-b31a-b8499ef306c9" positionType="Float" x="0" y="30" width="555" height="20"/>
                <textElement>
                    <font size="13" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[Test Title]]></text>
            </staticText>
            <textField isStretchWithOverflow="true">
                <reportElement uuid="f2898317-cfda-4e91-b52b-95da97d80d49" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="50" width="216" height="20" forecolor="#000000"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement textAlignment="Left" markup="none">
                    <font size="13" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["First row"]]></textFieldExpression>
            </textField>
        </band>
        <band height="40">
            <elementGroup>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement uuid="232505af-9176-4cd3-ae46-18184e3dc468" positionType="Float" stretchType="RelativeToTallestObject" x="216" y="0" width="339" height="40"/>
                    <box>
                        <pen lineWidth="0.25"/>
                        <topPen lineWidth="0.25"/>
                        <leftPen lineWidth="0.25"/>
                        <bottomPen lineWidth="0.25"/>
                        <rightPen lineWidth="0.25"/>
                    </box>
                    <textElement>
                        <font size="13"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{second}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement uuid="a6e45bfc-9c09-4db8-8cc0-2fabfedf7653" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="216" height="40" isPrintWhenDetailOverflows="true" forecolor="#000000"/>
                    <box>
                        <pen lineWidth="0.25"/>
                        <topPen lineWidth="0.25"/>
                        <leftPen lineWidth="0.25"/>
                        <bottomPen lineWidth="0.25"/>
                        <rightPen lineWidth="0.25"/>
                    </box>
                    <textElement textAlignment="Left" markup="none">
                        <font size="13" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA["Second row"]]></textFieldExpression>
                </textField>
            </elementGroup>
        </band>
        <band height="40" splitType="Stretch">
            <staticText>
                <reportElement uuid="1ae02b52-e3d7-4a4a-b805-e656f8734a49" stretchType="RelativeToTallestObject" x="216" y="0" width="339" height="40" isPrintWhenDetailOverflows="true"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement/>
                <text><![CDATA[]]></text>
            </staticText>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement uuid="232505af-9176-4cd3-ae46-18184e3dc468" stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" x="216" y="0" width="339" height="40"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement>
                    <font size="13"/>
                </textElement>
                <textFieldExpression><![CDATA[($F{third} == null) ? "" :
($F{third} ? "Yes" : "No")]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement uuid="a6e45bfc-9c09-4db8-8cc0-2fabfedf7653" positionType="Float" stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" x="0" y="0" width="216" height="40" forecolor="#000000"/>
                <box>
                    <pen lineWidth="0.25"/>
                    <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
                </box>
                <textElement textAlignment="Left" markup="none">
                    <font size="13" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Third row Third row Third row Third row Third row Third row Third row Third row Third rowThird row Third row Third row Third row Third rowThird rowThird rowThird row Third row Third row "]]></textFieldExpression>
            </textField>
        </band>
        <band height="40">
            <elementGroup>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement uuid="232505af-9176-4cd3-ae46-18184e3dc468" positionType="Float" stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" x="216" y="0" width="339" height="40" isPrintWhenDetailOverflows="true"/>
                    <box>
                        <pen lineWidth="0.25"/>
                        <topPen lineWidth="0.25"/>
                        <leftPen lineWidth="0.25"/>
                        <bottomPen lineWidth="0.25"/>
                        <rightPen lineWidth="0.25"/>
                    </box>
                    <textElement>
                        <font size="13"/>
                    </textElement>
                    <textFieldExpression><![CDATA[($F{fourth} == null) ? "" :
($F{fourth} ? "Yes" : "No")]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement uuid="a6e45bfc-9c09-4db8-8cc0-2fabfedf7653" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="216" height="40" forecolor="#000000"/>
                    <box>
                        <pen lineWidth="0.25"/>
                        <topPen lineWidth="0.25"/>
                        <leftPen lineWidth="0.25"/>
                        <bottomPen lineWidth="0.25"/>
                        <rightPen lineWidth="0.25"/>
                    </box>
                    <textElement textAlignment="Left" markup="none">
                        <font size="13" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA["Fourth row Fourth row Fourth row Fourth row Fourth row Fourth row"]]></textFieldExpression>
                </textField>
            </elementGroup>
        </band>
        <band height="70">
            <elementGroup>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement uuid="93cd5464-2924-4403-8677-64558418afa1" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="216" height="40" forecolor="#000000"/>
                    <box>
                        <pen lineWidth="0.25"/>
                        <topPen lineWidth="0.25"/>
                        <leftPen lineWidth="0.25"/>
                        <bottomPen lineWidth="0.25"/>
                        <rightPen lineWidth="0.25"/>
                    </box>
                    <textElement textAlignment="Left" markup="none">
                        <font size="13" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA["Fiveth row Fiveth row Fiveth row Fiveth row Fiveth row Fiveth row"]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement uuid="4bf32279-7361-4d05-b652-e37e7f4c96ba" positionType="Float" stretchType="RelativeToTallestObject" x="216" y="0" width="339" height="40"/>
                    <box>
                        <pen lineWidth="0.25"/>
                        <topPen lineWidth="0.25"/>
                        <leftPen lineWidth="0.25"/>
                        <bottomPen lineWidth="0.25"/>
                        <rightPen lineWidth="0.25"/>
                    </box>
                    <textElement>
                        <font size="13"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{fiveth}]]></textFieldExpression>
                </textField>
            </elementGroup>
        </band>

我设法解决了您的问题,我认为这是一个错误(包括框架中的字段和/或设置
stretchType=“RelativeToBandHeight”
没有解决问题)

我可以看到的解决方法是
textField
中删除所有边框,第一个字段上的右边框除外,并在带有边框的框架中包含这些字段

<frame borderSplitType="DrawBorders">
    <reportElement x="0" y="0" width="555" height="40" uuid="d2be3f0d-da65-4a09-b9c1-9d85c2f0af39">
    </reportElement>
    <box>
        <topPen lineWidth="0.25"/>
        <leftPen lineWidth="0.25"/>
        <bottomPen lineWidth="0.25"/>
        <rightPen lineWidth="0.25"/>
    </box>
    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
        <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="216" height="40" forecolor="#000000" uuid="a6e45bfc-9c09-4db8-8cc0-2fabfedf7653"/>
        <box>
            <pen lineWidth="0.25"/>
            <topPen lineWidth="0.0"/>
            <leftPen lineWidth="0.0"/>
            <bottomPen lineWidth="0.0"/>
            <rightPen lineWidth="0.25"/>
        </box>
        <textElement textAlignment="Left" markup="none">
            <font size="13" isBold="true"/>
        </textElement>
        <textFieldExpression><![CDATA["Third row Third row Third row Third row Third row Third row Third row Third row Third rowThird row Third row Third row Third row Third rowThird rowThird rowThird row Third row Third row "]]></textFieldExpression>
    </textField>
    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
        <reportElement stretchType="RelativeToTallestObject" x="216" y="0" width="339" height="40" uuid="232505af-9176-4cd3-ae46-18184e3dc468"/>
        <textElement>
            <font size="13"/>
        </textElement>
        <textFieldExpression><![CDATA[($P{third} == null) ? "" :($P{third} ? "Yes" : "No")]]></textFieldExpression>
    </textField>
</frame>

frame
上的属性
borderSplitType=“DrawBorders”
定义在新页面上拆分时是否打印的下/上边框


有时在单元格周围放置框架会有所帮助。另外,您是否尝试过相对于束带高度的拉伸类型
?确定。我将尝试它,并在以后作出回应它的工作,但我添加了一个空白的静态文本对整个乐队的边框和一个小的静态文本的左侧部分,只有右边框。我从文本字段中删除了所有边框。但不幸的是,它不适用于HTML:(.在任何情况下-谢谢。我可以这样做。@Playmate你为什么不让框架为你做边框呢?),它对其他布局更干净。也许。我从来没有使用过框架。事实上,我对使用Jasper Report没有什么好感。我遇到过很多布局错误,它们都不是微不足道的。也许我做错了smth。而这个钩子就是h borders外观suspiciously@Playmate,我认为这与你如何布局更相关,例如,当导出为pdf时,最好将所有内容移到下一页。