1

我在我的 liferay 自定义 portlet 中使用 jasper 报告,我用 ireport 4.7.1 设计了我的报告,但我的问题是为什么用 html 和 pdf 生成的报告存在巨大差异。 html 格式和 pdf 格式..如何使从同一 jasper 文件生成的 html 和 pdf 报告相同.?我的意思是具有相同的外观和感觉..以下是我的 html 和 pdf 报告片段

HTML REPORT

HTML 报告

PDF REPORT

PDF 报告

以下是我的 jrxml 文件,我从中生成 .jasper,然后生成以上两个结果。

<?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="Campaign_Advertise_DateRange_Report" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true">
    <property name="ireport.zoom" value="0.9090909090909098"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="Table Dataset 1"/>
    <field name="advertisename" class="java.lang.String"/>
    <field name="camp_name" class="java.lang.String"/>
    <field name="ad_location" class="java.lang.String"/>
    <field name="clicked" class="java.lang.Integer"/>
    <field name="impression" class="java.lang.Integer"/>
    <field name="filter_start_date" class="java.util.Date"/>
    <field name="filter_end_date" class="java.util.Date"/>
    <variable name="CamapignTotal" class="java.lang.Integer" resetType="Group" resetGroup="Campaign Name" calculation="Sum">
        <variableExpression><![CDATA[$F{impression}]]></variableExpression>
    </variable>
    <variable name="CampaignGrandTotal" class="java.lang.Integer" calculation="Sum">
        <variableExpression><![CDATA[$F{impression}]]></variableExpression>
    </variable>
    <group name="Campaign Name">
        <groupExpression><![CDATA[$F{camp_name}]]></groupExpression>
        <groupFooter>
            <band height="21">
                <textField pattern="" isBlankWhenNull="true">
                    <reportElement style="table_TD" x="419" y="0" width="86" height="20"/>
                    <textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
                        <font isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$V{CamapignTotal}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement style="table_TD" x="346" y="0" width="73" height="20"/>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font isBold="true"/>
                    </textElement>
                    <text><![CDATA[Group Total :]]></text>
                </staticText>
            </band>
        </groupFooter>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="114">
            <staticText>
                <reportElement x="136" y="24" width="283" height="67"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="32" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Campaign Reports]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="2" width="30" height="20"/>
                <textElement>
                    <font fontName="Times New Roman" isBold="true"/>
                </textElement>
                <text><![CDATA[Date : ]]></text>
            </staticText>
            <textField pattern="MM/dd/yyyy">
                <reportElement x="30" y="2" width="100" height="20"/>
                <textElement textAlignment="Justified">
                    <font fontName="Times New Roman" isUnderline="true"/>
                </textElement>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="94" width="30" height="20"/>
                <textElement textAlignment="Right">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[From:]]></text>
            </staticText>
            <staticText>
                <reportElement x="136" y="94" width="19" height="20"/>
                <textElement textAlignment="Right">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[To:]]></text>
            </staticText>
            <textField>
                <reportElement x="30" y="94" width="96" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{filter_start_date}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="155" y="94" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{filter_end_date}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="419" y="94" width="131" height="20"/>
                <textElement textAlignment="Right">
                    <font size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Advertise Display Reports]]></text>
            </staticText>
            <image>
                <reportElement x="458" y="8" width="92" height="53"/>
                <imageExpression><![CDATA["D:\\Liferay\\liferay-plugins-sdk-6.1.1-ce-ga2-20120731132656558\\liferay-plugins-sdk-6.1.1\\portlets\\eMenuAdvertise-portlet\\docroot\\img\\eMenuLogo.png"]]></imageExpression>
            </image>
        </band>
    </title>
    <pageHeader>
        <band height="52">
            <staticText>
                <reportElement style="table_TD" mode="Transparent" x="0" y="31" width="100" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Advertise Name]]></text>
            </staticText>
            <staticText>
                <reportElement style="table_TD" mode="Transparent" x="346" y="31" width="73" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Clicked]]></text>
            </staticText>
            <staticText>
                <reportElement style="table_TD" mode="Transparent" x="250" y="31" width="96" height="20" isPrintInFirstWholeBand="true"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[AD Location]]></text>
            </staticText>
            <staticText>
                <reportElement style="table_TD" mode="Transparent" x="100" y="31" width="150" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Campaign Name]]></text>
            </staticText>
            <staticText>
                <reportElement style="table_TD" mode="Transparent" x="419" y="31" width="86" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Times New Roman" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Impression]]></text>
            </staticText>
        </band>
    </pageHeader>
    <detail>
        <band height="21" splitType="Immediate">
            <textField>
                <reportElement style="table_TD" mode="Transparent" x="0" y="-1" width="100" height="22"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="html">
                    <font fontName="Times New Roman"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{advertisename}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="table_TD" mode="Transparent" x="250" y="-1" width="96" height="22" backcolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="html">
                    <font fontName="Times New Roman"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{ad_location}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="table_TD" mode="Transparent" x="419" y="-1" width="86" height="22"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="html">
                    <font fontName="Times New Roman"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{impression}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="table_TD" mode="Transparent" x="100" y="-1" width="150" height="22"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="html">
                    <font fontName="Times New Roman"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{camp_name}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="table_TD" mode="Transparent" x="346" y="-1" width="73" height="22"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" markup="html">
                    <font fontName="Times New Roman"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{clicked}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <lastPageFooter>
        <band height="50">
            <staticText>
                <reportElement style="table_TD" x="346" y="0" width="73" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Grand Total :]]></text>
            </staticText>
            <textField isBlankWhenNull="false">
                <reportElement style="table_TD" x="419" y="0" width="86" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{CampaignGrandTotal}]]></textFieldExpression>
            </textField>
        </band>
    </lastPageFooter>
</jasperReport>

任何人都可以帮助我使两个报告的外观和感觉相同吗?

4

1 回答 1

2

您报告中的问题似乎是细节带中元素的高度,它们是 22 像素,带是 21,它们的顶部属性也是 -1,我建议您使带更大(或您的控件更小)并将 Top 属性设置为 0 或任何正值。

于 2012-12-21T15:48:22.050 回答