JRXML - Eliminating repeated header on the bottom

2019-07-14 04:55发布

We've got a problem when printing some PDF reports using JasperReports. These reports are basically a breakdown of all the sales made to a specific client over the course of the years.

We take information from a DB, transform it using Java, and print the reports in PDF. The problem is, in some rare cases, some headers appear repeated at the bottom of each page:

enter image description here

Ideally, we should be able to omit that loose header and keep only the one on the new page, but I can't seem to do it, at least via TIBCO Jaspersoft Studio.

I don't actually know much about these reports, but any information you need to help, feel free to ask.

Thanks in advance.

EDIT: Following Petter Friberg's comment, here's parts of the JRXML being used in this report. I omitted some parts that follow the same properties, but i think this should be clear enough.

    <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="Historique" language="groovy" pageWidth="595" pageHeight="842" columnWidth="483" leftMargin="56" rightMargin="56" topMargin="43" bottomMargin="43" isSummaryWithPageHeaderAndFooter="true" resourceBundle="reportLabels" whenResourceMissingType="Empty" uuid="80db05e1-8ca3-483d-86cc-5947dc62296b">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="mm"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="mm"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="mm"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="mm"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
    <template><![CDATA["/jasper/styles_letter.jrtx"]]></template>
    <style name="Table Group Header" mode="Opaque" forecolor="#000000" backcolor="#99CCFF" vTextAlign="Middle" fontName="Arial" fontSize="10" isBold="true" pdfFontName="Helvetica-Bold"/>
    <!-- ... multiple styles -->
    <parameter name="title" class="java.lang.String"/>
        <!-- ... multiple parameters-->
    <parameter name="addressCity" class="java.lang.String"/>
    <field name="reduction" class="java.lang.String">
        <fieldDescription><![CDATA[reduction]]></fieldDescription>
    </field>
        <!-- ... multiple fields -->
    <field name="year" class="java.lang.String"/>
    <group name="DescriptionGroup">
        <groupExpression><![CDATA[$F{year}]]></groupExpression>
        <groupHeader>
            <band height="30">
                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                <textField evaluationTime="Group" evaluationGroup="DescriptionGroup" bookmarkLevel="2">
                    <reportElement style="Table Group Header" mode="Opaque" x="0" y="0" width="483" height="15" printWhenGroupChanges="DescriptionGroup" backcolor="#B0B0B0" uuid="f626bb36-a919-48b9-98b3-756d1ce9812b">
                        <property name="local_mesure_unitx" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.x" value="px"/>
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <printWhenExpression><![CDATA[new Boolean($P{emptyList} != true)]]></printWhenExpression>
                    </reportElement>
                    <box leftPadding="10">
                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement markup="none">
                        <font size="9" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{year}]]></textFieldExpression>
                </textField>
                <!-- ... multiple text fields following the same principle -->
            </band>
        </groupHeader>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <!-- this only appears in the first page, has all the customer info -->
    </title>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="25" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            <textField pattern="" isBlankWhenNull="true">
                <reportElement style="Zebra" mode="Opaque" x="0" y="0" width="130" height="25" uuid="234d3832-bd30-40a0-b8e5-eac964158000">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="local_mesure_unitx" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <printWhenExpression><![CDATA[new Boolean($P{emptyList} != true)]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="8" isBold="false"/>
                    <paragraph leftIndent="3"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{article}]]></textFieldExpression>
            </textField>
            <!-- ... multiple fields following the same principle. this is the body of each sub-table, showing the info for each year -->
        </band>
    </detail>
    <pageFooter>
        <band height="25" splitType="Stretch">
            <!-- ... -->
        </band>
    </pageFooter>
    <summary>
        <band height="40" splitType="Stretch">
            <!-- ... shows a summary of all the info shown on each table -->
        </band>
    </summary>
</jasperReport>

Thanks in advance.

1条回答
干净又极端
2楼-- · 2019-07-14 05:19

You are using a group the generate the header, so you can use this attribute minHeightToStartNewPage, to determine how much space needs to remain otherwise break to new page.

<group name="DescriptionGroup" minHeightToStartNewPage="60">

or if you like to force it to always start on new page

<group name="DescriptionGroup" isStartNewPage="true">
查看更多
登录 后发表回答