The text is rendering clipped ignoring isStretchWithOverflow property value using PDF exporter

帅比萌擦擦* 提交于 2019-12-12 17:40:01

问题


Is it possible to wrap text in a groupHeader? I have it working in the detail section, but the text within the group does not seem to want to wrap. I have tried every combination for wrapping I could think of or find from google.

<style name="reportProject" isDefault="false" fontName="Times" fontSize="10" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false"/>
<group name="PROJHEADER" minHeightToStartNewPage="60">
    <groupExpression><![CDATA[$F{projectHeader}]]>
    </groupExpression>
    <groupHeader>
        <band height="40" splitType="Stretch">
            <printWhenExpression><![CDATA[Boolean.valueOf($F{projectHeader}.length() > 0)]]>
            </printWhenExpression>
            <textField  isStretchWithOverflow="true"  isBlankWhenNull="true"
                                evaluationTime="Group" evaluationGroup="PROJHEADER" bookmarkLevel="1">
                <reportElement positionType="Float" style="reportProject" mode="Opaque" x="0" y="5" 
                                width="515" height="15" backcolor="#C0C0C0"
                                stretchType="RelativeToBandHeight"/>
                <box leftPadding="10">
                    <bottomPen lineWidth="1.0"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle" />
                <textFieldExpression class="java.lang.String"><![CDATA[$F{projectHeader}]]>
                </textFieldExpression>
            </textField>
        </band>
    </groupHeader>
</group>

回答1:


Setting the isStretchWithOverflow property with true value helps me.

The sample:

<group name="citygr">
    <groupExpression><![CDATA[$F{CITY}]]></groupExpression>
    <groupHeader>
        <band height="20">
            <textField isStretchWithOverflow="true">
                <reportElement x="0" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{CITY} + " text1 txt2 longtext3 verylonglongtxt4 long1234567890verylongtext5 txt6 text6 longtext7"]]></textFieldExpression>
            </textField>
        </band>
    </groupHeader>
</group>

The result will be:

I'm using the iReport 4.1.3.

You can also try to set net.sf.jasperreports.export.pdf.force.linebreak.policy property. Just add this this property in your jrxml file. You can read about this property here.

The sample:

<jasperReport ...>
    <property name="net.sf.jasperreports.export.pdf.force.linebreak.policy" value="true"/>



回答2:


This is what I ended up with, that works.

<jasperReport ...>
   <property name="net.sf.jasperreports.export.pdf.force.linebreak.policy" value="true"/>
   .....
    <group name="PROJHEADER" minHeightToStartNewPage="60">
        <groupExpression><![CDATA[$F{projectHeader}]]>
        </groupExpression>
        <groupHeader>
            <band height="40" splitType="Stretch">
                <printWhenExpression><![CDATA[Boolean.valueOf($F{projectHeader}.length() > 0)]]></printWhenExpression>
                <textField  isStretchWithOverflow="true"  isBlankWhenNull="true">
                    <reportElement  style="reportProject" x="0" y="5" 
                        width="400" height="15" backcolor="#C0C0C0"/>
                    <textElement textAlignment="Left" verticalAlignment="Middle" />
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{projectHeader}]]>
                    </textFieldExpression>
                </textField>
            </band>
        </groupHeader>
    </group>


来源:https://stackoverflow.com/questions/8919645/the-text-is-rendering-clipped-ignoring-isstretchwithoverflow-property-value-usin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!