【问题标题】:Cover blank space of image by other elements of Jasper Report用 Jasper Report 的其他元素覆盖图像的空白区域
【发布时间】:2017-03-31 16:29:40
【问题描述】:

我的图像高度为 360 像素,宽度为 900 像素。根据我的情况,有时图像会是空白的,因此它不会显示在 PDF 或 EXCEL 中。

此时,当图像不是根据其设置的“y”轴定位的其他元素时。因此形成了一个间隙。

那么当图像不是它们时,如何将它们所有其他元素的位置设置为顶部。

<image isUsingCache="true" onErrorType="Icon">
                <reportElement x="448" y="0" width="402" height="300" uuid="d8d19734-1711-461d-bdb8-c8c7130a6eb2">
                    <printWhenExpression><![CDATA[($P{chartImg2}!=null ? true : false)]]></printWhenExpression>
                </reportElement>
                <imageExpression><![CDATA[$P{chartImg2}]]></imageExpression>
            </image>
            <textField>
                <reportElement style="REPORT_TITLE" mode="Opaque" x="0" y="320" width="850" height="30" uuid="aabbe2ed-96eb-4246-8bda-16187228c116">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Center">
                    <font isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{campaign_name}+"- Links Report"]]></textFieldExpression>
            </textField>

所以,现在您可以看到图像的高度比文本字段的高度为 320 像素,因此图像不是它们的,但文本字段将在 320 像素之后显示。它在 PDF 中看起来很糟糕。所以我想如果图像不是他们上面的所有元素移位。

【问题讨论】:

标签: image jasper-reports height shift


【解决方案1】:

我的问题得到了解决。您需要将元素添加到框架中,这取决于条件。在上面的问题中,图像可能存在也可能不存在。

所以在这种情况下,将此图像添加到框架中,并将其他元素的位置更改为浮动。 (所有元素都有一个可用的属性positionedType="float")

宾果游戏!!!问题解决了。

【讨论】: