我的图像高度为360px,宽度为900px。根据我的情况,有时图像将是空白的,因此它不会显示在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>
因此,现在您可以看到图像的高度为300,而不是文本字段位于320px,因此图像不是它们的静止文本字段将在320px之后显示。它在 PDF 中看起来很糟糕。所以我希望如果图像不是他们的,那么上面的所有元素都移动了。
我得到了我的问题的解决方案。您需要将元素添加到框架中,这取决于条件。在上面的问题中,图像可能存在也可能不存在。
因此,在这种情况下,将此图像添加到框架中,并更改了其他元素以浮动定位。(在所有元素中都有一个属性 positionedType="float"(
宾果游戏!!!问题解决了。