【问题标题】:How can I align a variable height lastPageFooter in Jasper reports jrxml to the bottom of the page?如何将 Jasper 报告 jrxml 中的可变高度 lastPageFooter 对齐到页面底部?
【发布时间】:2017-01-25 12:23:30
【问题描述】:

我有以下报告:

<?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="demo" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <style name="highlight box" mode="Opaque" backcolor="#D9D9D9">
        <box padding="2" />
    </style>


    <lastPageFooter>
        <band height="30">
            <textField isStretchWithOverflow="true">
                <reportElement style="highlight box" x="0" y="0" width="320" height="1" />
                <textFieldExpression><![CDATA["This is a short footer content\nIt contains multiple lines"]]></textFieldExpression>
            </textField>
        </band>
    </lastPageFooter>
</jasperReport>

如您所见,报告只包含 lastPageFooter,其中包含文本字段宽度动态 (isStretchWithOverflow="true") 高度。

然而,Jasper 似乎总是将lastPageFooter 放置在页面结束前 30 像素处(如&lt;band height="30"&gt; 中所定义)。如果由于 textField 的高度而 30 像素不够,则带区会被拉伸,但它会向下拉伸,越过页面末尾而不是向上。这会导致页脚的某些内容不被呈现。实际上上面的报告是这样呈现的:

您可以看到 textField 中的第二行丢失了。我当然可以增加波段高度,比如说...... 100 像素:

在这种情况下,文本字段的第二行被渲染,但 100px 显然太大了,页脚不再位于页面末尾。

在这种情况下,文本字段包含静态文本,因此我可以尝试高度的值,以使其适合,但在现实世界中,文本字段的内容来自变量。如何让页脚以动态高度显示在页面底部?

【问题讨论】:

    标签: jasper-reports


    【解决方案1】:

    尝试更改页脚上的拆分类型。您可以尝试“拉伸”或“预防”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-25
      • 1970-01-01
      • 2019-05-27
      • 2016-01-18
      • 2012-10-26
      • 1970-01-01
      相关资源
      最近更新 更多