1

我有一个包含三个报告组的主要报告。每个报告组标题都有一个子报告。当我使用 jasper 报告生成 PDF 文件时

  1. 它在子报告之间添加一些空白,即,如果第一个子报告自动占据第一页的 60% 以上,则第二个子报告将从新页面开始。
    我不能使用 ispageignoration,因为我们将为多条记录生成 pdf,其中每条记录都应该从新页面开始。
  2. 它在最后生成一个空白页,只有页眉

第二个报告中的文本字段(value1,value2...value6)最多可以有 2000 个字符。

谁能帮帮我吗..

主报告 report1.jrxml 文件

    <?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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20">
        <parameter name="logoStream" class="java.awt.Image" isForPrompting="false"/>
        <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
            <defaultValueExpression><![CDATA["D:\\Other  Drive\\eHRM\\17365\\"]]></defaultValueExpression>
        </parameter>
        <field name="id" class="java.lang.String"/>
        <field name="dataSource1" class="net.sf.jasperreports.engine.JRDataSource"/>
        <field name="dataSource2" class="net.sf.jasperreports.engine.JRDataSource"/>
        <field name="dataSource3" class="net.sf.jasperreports.engine.JRDataSource"/>
        <group name="Group1" isStartNewPage="true">
            <groupExpression><![CDATA[$F{id}]]></groupExpression>
            <groupHeader>
                <band height="20">
                    <subreport>
                        <reportElement x="-30" y="0" width="535" height="20" isRemoveLineWhenBlank="true"/>
                        <dataSourceExpression><![CDATA[$F{dataSource1}]]></dataSourceExpression>
                        <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "/report1_subreport1.jasper"]]></subreportExpression>
                    </subreport>
                </band>
            </groupHeader>
        </group>
        <group name="Group2">
            <groupExpression><![CDATA[$F{id}]]></groupExpression>
            <groupHeader>
                <band height="20">
                    <subreport>
                        <reportElement x="-30" y="0" width="535" height="20" isRemoveLineWhenBlank="true"/>
                        <dataSourceExpression><![CDATA[$F{dataSource2}]]></dataSourceExpression>
                        <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "/report1_subreport2.jasper"]]></subreportExpression>
                    </subreport>
                </band>
            </groupHeader>
        </group>
        <group name="group3">
            <groupExpression><![CDATA[$F{id}]]></groupExpression>
            <groupHeader>
                <band height="20">
                    <subreport>
                        <reportElement x="-30" y="0" width="535" height="20" isRemoveLineWhenBlank="true"/>
                        <dataSourceExpression><![CDATA[$F{dataSource3}]]></dataSourceExpression>
                        <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "/report1_subreport3.jasper"]]></subreportExpression>
                    </subreport>
                </band>
            </groupHeader>
        </group>
        <background>
            <band splitType="Stretch"/>
        </background>
        <pageHeader>
            <band height="50">
                <image>
                    <reportElement x="0" y="0" width="100" height="50"/>
                    <imageExpression><![CDATA[(java.awt.Image)$P{logoStream}]]></imageExpression>
                </image>
                <textField>
                    <reportElement x="510" y="0" width="20" height="20"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$V{PAGE_NUMBER}.toString()]]></textFieldExpression>
                </textField>
            </band>
        </pageHeader>
    </jasperReport>

三个子报告的格式与下面的 jrxml 文件相同

        <?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="report1_subreport1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="0" bottomMargin="0">
        <field name="title1" class="java.lang.String"/>
        <field name="value1" class="java.lang.String"/>
        <field name="title2" class="java.lang.String"/>
        <field name="value2" class="java.lang.String"/>
        <field name="title3" class="java.lang.String"/>
        <field name="value3" class="java.lang.String"/>
        <field name="title4" class="java.lang.String"/>
        <field name="value4" class="java.lang.String"/>
        <field name="title5" class="java.lang.String"/>
        <field name="value5" class="java.lang.String"/>
        <field name="title6" class="java.lang.String"/>
        <field name="value6" class="java.lang.String"/>
        <background>
            <band splitType="Stretch"/>
        </background>
        <detail>
            <band height="161" splitType="Stretch">
                <elementGroup>
                    <line>
                        <reportElement x="0" y="27" width="535" height="5" forecolor="#FFFFFF">
                            <printWhenExpression><![CDATA[($F{value2} == null || $F{value2}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]></printWhenExpression>
                        </reportElement>
                    </line>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="0" y="33" width="120" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{title2}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="120" y="33" width="415" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression>
                    </textField>
                </elementGroup>
                <elementGroup>
                    <line>
                        <reportElement x="0" y="54" width="535" height="5" forecolor="#FFFFFF">
                            <printWhenExpression><![CDATA[($F{value3} == null || $F{value3}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]></printWhenExpression>
                        </reportElement>
                    </line>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="0" y="60" width="120" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{title3}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="120" y="60" width="415" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{value3}]]></textFieldExpression>
                    </textField>
                </elementGroup>
                <elementGroup>
                    <line>
                        <reportElement x="0" y="81" width="535" height="5" forecolor="#FFFFFF">
                            <printWhenExpression><![CDATA[($F{value4} == null || $F{value4}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]></printWhenExpression>
                        </reportElement>
                    </line>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="0" y="87" width="120" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{title4}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="120" y="87" width="415" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{value4}]]></textFieldExpression>
                    </textField>
                </elementGroup>
                <elementGroup>
                    <line>
                        <reportElement x="0" y="108" width="535" height="5" forecolor="#FFFFFF">
                            <printWhenExpression><![CDATA[($F{value5} == null || $F{value5}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]></printWhenExpression>
                        </reportElement>
                    </line>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="0" y="114" width="120" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{title5}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="120" y="114" width="415" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{value5}]]></textFieldExpression>
                    </textField>
                </elementGroup>
                <elementGroup>
                    <line>
                        <reportElement x="0" y="135" width="535" height="5" forecolor="#FFFFFF">
                            <printWhenExpression><![CDATA[($F{value6} == null || $F{value6}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]></printWhenExpression>
                        </reportElement>
                    </line>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="0" y="141" width="120" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{title6}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="120" y="141" width="415" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{value6}]]></textFieldExpression>
                    </textField>
                </elementGroup>
                <elementGroup>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="0" y="6" width="120" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{title1}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="120" y="6" width="415" height="20" isRemoveLineWhenBlank="true"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{value1}]]></textFieldExpression>
                    </textField>
                    <line>
                        <reportElement x="0" y="0" width="535" height="5" forecolor="#FFFFFF">
                            <printWhenExpression><![CDATA[($F{value1} == null || $F{value1}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]></printWhenExpression>
                        </reportElement>
                    </line>
                </elementGroup>
            </band>
        </detail>
    </jasperReport>

一个人可能有 n 家公司,所以我将公司名称、工作简介、项目描述放在子报告中。

---------------------------------------------------------------
Name: XXX
DOB: XX-XX-XXXX
Personal Profile: (** this field may have 2000 characters****)
Skill Sets : (** this also will have 2000 characters**)

Professional Experience:

Company name: XXXX
Job Profile: (** this also will have 2000 characters**)
Project Description :(** this also will have 2000 characters**)

Company name: YYYYY
Job Profile: (** this also will have 2000 characters**)
Project Description :(** this also will have 2000 characters**)
-----------------------------------------------------------------

我的要求是生成与其类似的 PDf。

4

0 回答 0