Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The nice solution was described in this post: <a href="https://stackoverflow.com/q/5138360/876298">Compare current page number with last page number</a>. I've used it in the sample below.</p> <hr> <h3>Short description</h3> <p>With help of <em>Summary</em> page we can set the <em>flag</em> that the last page was already drawn.<br/> For initializing this <em>flag</em> we can use the <em>printWhenExpression</em> of the <em>Summary</em> band.</p> <h3>The sample</h3> <p>The <em>jrxml</em> file:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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="last_page_on_page_footer" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="37b03978-a847-40ab-bd19-40bd48de326d"&gt; &lt;queryString&gt; &lt;![CDATA[SELECT TASK FROM TASKS]]&gt; &lt;/queryString&gt; &lt;field name="TASK" class="java.lang.String"/&gt; &lt;detail&gt; &lt;band height="50" splitType="Stretch"&gt; &lt;textField&gt; &lt;reportElement uuid="bec3ccda-ea30-49fa-a0ad-5bb74a2187a5" x="0" y="0" width="100" height="20"/&gt; &lt;textElement/&gt; &lt;textFieldExpression&gt;&lt;![CDATA[$F{TASK}]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;/band&gt; &lt;/detail&gt; &lt;pageFooter&gt; &lt;band height="54" splitType="Stretch"&gt; &lt;textField evaluationTime="Report"&gt; &lt;reportElement uuid="5e4bb895-fd64-4627-bd35-ca1ed71f8dc1" x="455" y="0" width="100" height="20"&gt; &lt;printWhenExpression&gt;&lt;![CDATA[!$P{REPORT_PARAMETERS_MAP}.containsKey("LastPageNumber")]]&gt;&lt;/printWhenExpression&gt; &lt;/reportElement&gt; &lt;textElement/&gt; &lt;textFieldExpression&gt;&lt;![CDATA["initials: ___________"]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;textField&gt; &lt;reportElement uuid="788fbc43-92cc-4540-abeb-8fa9bf48d25c" x="0" y="0" width="80" height="20"/&gt; &lt;textElement textAlignment="Right"/&gt; &lt;textFieldExpression&gt;&lt;![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;textField evaluationTime="Report"&gt; &lt;reportElement uuid="95286826-b864-46f8-9922-fc0e2f023ba5" x="80" y="0" width="40" height="20"/&gt; &lt;textElement/&gt; &lt;textFieldExpression&gt;&lt;![CDATA[" " + $V{PAGE_NUMBER}]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;textField evaluationTime="Report"&gt; &lt;reportElement uuid="25ccab25-ccd2-4187-8a9b-dff54276042e" x="455" y="0" width="100" height="20"&gt; &lt;printWhenExpression&gt;&lt;![CDATA[$P{REPORT_PARAMETERS_MAP}.containsKey("LastPageNumber")]]&gt;&lt;/printWhenExpression&gt; &lt;/reportElement&gt; &lt;textElement/&gt; &lt;textFieldExpression&gt;&lt;![CDATA["Signature: ___ "]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;/band&gt; &lt;/pageFooter&gt; &lt;summary&gt; &lt;band height="20"&gt; &lt;printWhenExpression&gt;&lt;![CDATA[new Boolean(($P{REPORT_PARAMETERS_MAP}.put( "LastPageNumber",$V{PAGE_NUMBER}).equals("dummyPrintWhen")) || Boolean.TRUE)]]&gt;&lt;/printWhenExpression&gt; &lt;/band&gt; &lt;/summary&gt; &lt;/jasperReport&gt; </code></pre> <p>The report's design (in <em>iReport</em>):</p> <p><img src="https://i.stack.imgur.com/hPRuD.png" alt="enter image description here"></p> <p>The result will be. First page (1 of 2):</p> <p><img src="https://i.stack.imgur.com/6q6qN.png" alt="enter image description here"></p> <p>And the second (the last page):</p> <p><img src="https://i.stack.imgur.com/YxooB.png" alt="enter image description here"></p> <p>In case only one page the result will be:</p> <p><img src="https://i.stack.imgur.com/UoAAw.png" alt="enter image description here"></p> <p>In my sample I've placed one <em>textField</em> behind the other one.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload