0
votes

I'm currently working with Jaspersoft Studio (version 5.6.2.final) to create PDF documents. I'm currently running into a problem which I could use some help with.

I have one master report which contains 3 subreports. Each of the subreports is full fledged document with their own header, detail and (last)pageFooter band. Each of the subreports are created in their own detail band with pagebreak so they each subreports start on a new page. So far there aren't any issues.

Now the customer wants a page number on every page on a specific place in the document, this place corresponds to a specific part of the header of each of the subreports. See the image below:

Location of the pagenumber http://puu.sh/dAZzg/edaa1285c4.png

What I did to enable this is create a pageHeader in the master report which contains the pageNumber. Then I gave each of the subreports a negative y-coordinate so they slide over the pageHeader thus printing the pageNumber on exactly the right location. This works partially.

<pageHeader>
    <band height="159">
        <property name="local_mesure_unitheight" value="cm"/>
        <textField>
            <reportElement x="483" y="145" width="31" height="14" uuid="f512ea15-2e4b-4c63-bf92-61b990d9c461">
                <property name="local_mesure_unitheight" value="cm"/>
                <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                <property name="local_mesure_unity" value="cm"/>
                <property name="com.jaspersoft.studio.unit.y" value="cm"/>
            </reportElement>
            <textElement textAlignment="Left">
                <font fontName="Amerigo BT"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
    </band>
</pageHeader>
<detail>
    <band height="83" splitType="Stretch">
        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
        <subreport>
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="-56" y="-175" width="573" height="83" uuid="5e4141a0-ac50-485a-8269-40b607c67466">
                <property name="local_mesure_unity" value="cm"/>
                <property name="com.jaspersoft.studio.unit.y" value="cm"/>
                <property name="local_mesure_unitx" value="cm"/>
                <property name="com.jaspersoft.studio.unit.x" value="cm"/>
            </reportElement>
            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//idbfyl:fiscalYearReportLetter")]]></dataSourceExpression>
            <subreportExpression><![CDATA["FiscalYearReportLetter.jasper"]]></subreportExpression>
        </subreport>
    </band>
    <band height="83" splitType="Stretch">
        <break>
            <reportElement x="0" y="0" width="513" height="1" uuid="43e0cd6d-cc0b-4ce9-ae2f-0d8d2b498896"/>
        </break>
        <subreport>
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="-56" y="-175" width="573" height="70" uuid="df524b80-9db1-43b7-9c45-3b8ea21c8081">
                <property name="local_mesure_unity" value="cm"/>
                <property name="com.jaspersoft.studio.unit.y" value="cm"/>
            </reportElement>
            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//idbfyvr:fiscalYearValueReport")]]></dataSourceExpression>
            <subreportExpression><![CDATA["FiscalYearValueReport.jasper"]]></subreportExpression>
        </subreport>
    </band>
    <band height="83" splitType="Stretch">
        <break>
            <reportElement x="0" y="0" width="513" height="1" uuid="bcddb440-2fdd-49c2-98cc-7978260c8d34"/>
        </break>
        <subreport>
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="-56" y="-175" width="573" height="70" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" uuid="df524b80-9db1-43b7-9c45-3b8ea21c8081">
                <property name="local_mesure_unity" value="cm"/>
                <property name="com.jaspersoft.studio.unit.y" value="cm"/>
            </reportElement>
            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//ibdfyir:fiscalYearIncomeReport")]]></dataSourceExpression>
            <subreportExpression><![CDATA["FiscalYearIncomeReport.jasper"]]></subreportExpression>
        </subreport>
    </band>
</detail>

Every first page of a subreports prints on the correct location, but on every page after the first one the subreport is printed below the pageHeader, it seems like the negative y coordinate is reset to 0.

Subreport start below the pageheader

Is there a way to force every page of a subreport to start from the same negative y-coordinate, or is there another way to achieve what I need?

Cheers, Rick

PS. The example pictures start from page 2 because the first subreport only consists of 1 page. I've also removed sensitive data from the screenshot so don't worry about the white spaces you see.

1

1 Answers

0
votes

I had similar problem. Try to place the pageNumber in the details band of the master report and mark it isPrintWhenDetailOverFlows to get pageNumber to print on all pages when subreport overflows.