为什么我的ireport中的图像会产生额外的空白页?

时间:2015-12-29 19:28:17

标签: jasper-reports

我的报告只生成带有图片的pdf文件。 当图像大小为800x1054时;图像非常适合(每页1张图像)。 但是,例如,如果图像大小为(667x1054),则图像适合页面,并在667x1054图像上方生成一个额外的空白页。

这是我的ireport代码:

<?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>

1 个答案:

答案 0 :(得分:1)

如果您的格式是宽x高(800,667是宽度,1054是高)

图片上的属性scaleImage

  

RealHeight - 可以垂直拉伸图像以匹配实际图像   图像高度,同时保留图像的声明宽度   元件。

因为它需要保持宽度为555px,宽度为667的图像可以将其高度拉伸到宽度为800的图像。这将导致宽度为667的图像将使用更多高度,因此您可能会看到溢出。

<强>解决方案

  1. 减少reportElement的宽度(以便667x1054也适合)

  2. 设置reportElement的高度和宽度以填充页面并使用scaleImage="RetainShape"

相关问题