为什么我的 ireport 中的图像会生成一个额外的空白页?
why is the image in my ireport generating an extra blank page?
我有一份报告生成了一个只有图像的 pdf 文件。
当图像尺寸为 800x1054 时;图像非常适合(每页 1 张图像)。
但是例如,如果图片大小为 (667x1054),则图片适合页面,它会在 667x1054 图片上方生成一个额外的空白页。
这是我的报告代码:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ReporteExpediente" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d978dab3-2ee3-486f-b62c-7e6817ee39da">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="imagen" class="java.io.InputStream">
<fieldDescription><![CDATA[imagen]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="166" splitType="Stretch">
<image scaleImage="RealHeight">
<reportElement x="0" y="0" width="555" height="166" uuid="9b2798da-ca28-4aeb-a8de-8299718c3e40"/>
<imageExpression><![CDATA[$F{imagen}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
如果您的格式是宽 x 高(800,667 是宽,1054 是高)
您在图片上的属性 scaleImage
:
RealHeight - the image can be stretched vertically to match the actual
image height, while preserving the declared width of the image
element.
因为它需要保留你的宽度 555px,所以宽度为 667 的图像可以比宽度为 800 的图像拉伸它的高度更多。这将导致宽度为 667 的图像将使用更多的高度,因此你可能会看到溢出。
解决方案
减小 reportElement 的宽度(以便 667x1054 也适合)
设置您的 reportElement 的高度和宽度以填充页面并使用 scaleImage="RetainShape"
我有一份报告生成了一个只有图像的 pdf 文件。 当图像尺寸为 800x1054 时;图像非常适合(每页 1 张图像)。 但是例如,如果图片大小为 (667x1054),则图片适合页面,它会在 667x1054 图片上方生成一个额外的空白页。
这是我的报告代码:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ReporteExpediente" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d978dab3-2ee3-486f-b62c-7e6817ee39da">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="imagen" class="java.io.InputStream">
<fieldDescription><![CDATA[imagen]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="166" splitType="Stretch">
<image scaleImage="RealHeight">
<reportElement x="0" y="0" width="555" height="166" uuid="9b2798da-ca28-4aeb-a8de-8299718c3e40"/>
<imageExpression><![CDATA[$F{imagen}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
如果您的格式是宽 x 高(800,667 是宽,1054 是高)
您在图片上的属性 scaleImage
:
RealHeight - the image can be stretched vertically to match the actual image height, while preserving the declared width of the image element.
因为它需要保留你的宽度 555px,所以宽度为 667 的图像可以比宽度为 800 的图像拉伸它的高度更多。这将导致宽度为 667 的图像将使用更多的高度,因此你可能会看到溢出。
解决方案
减小 reportElement 的宽度(以便 667x1054 也适合)
设置您的 reportElement 的高度和宽度以填充页面并使用
scaleImage="RetainShape"