在jasper报告的左侧显示垂直图像

时间:2015-09-22 05:17:26

标签: jasper-reports

enter image description here

我想在附件中显示图像(借助 iReport )。我也想在第一页显示它。我该如何设计呢?

1 个答案:

答案 0 :(得分:3)

使用IReport中的Background部分添加图像。 在所有其他部分中,对所有元素使用左边距,以便图像不会与其他元素重叠。

使用下面的示例代码

<?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="bgreport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="0.9090909090909102"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="637"/>
    <queryString>
        <![CDATA[select 1 from dual]]>
    </queryString>
    <field name="?column?" class="java.lang.Integer"/>
    <background>
        <band height="802" splitType="Stretch">
            <image scaleImage="Clip">
                <reportElement x="0" y="0" width="113" height="802"/>
                <imageExpression class="java.lang.String"><![CDATA["/home/manideep/manideep/temp/cherry.jpg"]]></imageExpression>
            </image>
        </band>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="112" y="0" width="100" height="79"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Title]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch">
            <staticText>
                <reportElement x="112" y="0" width="100" height="35"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Page Header]]></text>
            </staticText>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch">
            <staticText>
                <reportElement x="112" y="0" width="100" height="61"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Column Header]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <staticText>
                <reportElement x="112" y="0" width="100" height="125"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Detail Band]]></text>
            </staticText>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch">
            <staticText>
                <reportElement x="112" y="0" width="100" height="45"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Column Footer]]></text>
            </staticText>
        </band>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch">
            <staticText>
                <reportElement x="112" y="0" width="100" height="54"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Page Footer]]></text>
            </staticText>
        </band>
    </pageFooter>
    <summary>
        <band height="303" splitType="Stretch">
            <staticText>
                <reportElement stretchType="RelativeToBandHeight" x="112" y="0" width="100" height="303"/>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Summary]]></text>
            </staticText>
        </band>
    </summary>
</jasperReport>