【问题标题】:Subreport with negative y coordinate prints wrong on second page with jaspersoft带有负 y 坐标的子报表在 jaspersoft 的第二页上打印错误
【发布时间】:2014-12-19 13:07:23
【问题描述】:

我目前正在使用 Jaspersoft Studio(版本 5.6.2.final)创建 PDF 文档。我目前遇到了一个问题,我可以寻求帮助。

我有一份包含 3 个子报告的主报告。每个子报表都是完整的文档,具有自己的标题、详细信息和(最后)页脚带。每个子报表都是在它们自己的带有分页符的详细信息带中创建的,因此它们每个子报表都从一个新页面开始。到目前为止没有任何问题。

现在客户希望在文档中特定位置的每一页上都有一个页码,该位置对应于每个子报表标题的特定部分。见下图:

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

我所做的是在包含 pageNumber 的主报告中创建一个 pageHeader。然后我给每个子报表一个负的 y 坐标,所以它们在 pageHeader 上滑动,从而在正确的位置打印 pageNumber。这部分有效。

<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>

子报表的每一页都打印在正确的位置,但在第一页之后的每一页上,子报表都打印在 pageHeader 下方,似乎负 y 坐标被重置为 0。

有没有办法强制子报表的每一页都从相同的负 y 坐标开始,或者有其他方法可以实现我的需要吗?

干杯, 瑞克

PS。示例图片从第 2 页开始,因为第一个子报表仅包含 1 页。我还从屏幕截图中删除了敏感数据,所以不要担心你看到的空白。

【问题讨论】:

    标签: jasper-reports subreport page-numbering


    【解决方案1】:

    我有类似的问题。尝试将 pageNumber 放在主报表的详细信息带中,并将其标记为 isPrintWhenDetailOverFlows,以便在子报表溢出时在所有页面上打印 pageNumber。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多