justin.neil Posted April 20, 2015 Share Posted April 20, 2015 Hello,I am currently using Jasper 4.5.1 to generate some reports programmatically. I've noticed an issue with printing page numbers in my page footer band.The idea is to print "Page X of Y"When I create a report using iReport, this works no problem. When creating in code, I add two text fields which have the following setup:1. JRDesignTextField with expression = "Page " + ${PAGE_NUMBER} + " of " and an evaluation time of "NOW"2. JRDesignTextField with expression = " " + ${PAGE_NUMBER} and an evaluation time of "Report". Also printRepeatedValues = trueThe first text field evaluates as expected and a page number is displayed on each page. The second text field appears to be blank. I've commented out the code that adds the first field, and still nothing displays on the second. Note - I am also using the JRFileVirtualizer when filling the report, if that matters.I've generated the XML for the report for sanity purposes, so I can check it against a report that I've previously written in iReport (which works). Here is the page footer output:<pageFooter> <band height="20" splitType="Stretch"> <textField isStretchWithOverflow="true" evaluationTime="Report" isBlankWhenNull="true"> <reportElement x="770" y="0" width="30" height="14"/> <textElement textAlignment="Left"> <font fontName="Open Sans" size="12" isBold="true"/> </textElement> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement x="700" y="0" width="70" height="14"/> <textElement textAlignment="Right"> <font fontName="Open Sans" size="12" isBold="true"/> </textElement> <textFieldExpression><![CDATA["Page"+ " " + $V{PAGE_NUMBER}+ " " + "of"]]></textFieldExpression> </textField> </band> </pageFooter>[/code]I've read that the order in which you insert the elements into the report might matter, but changing the order of insertion does not change anything.I'm wondering if I am missing a step or not setting a flag correctly? We're planning on upgrading to Jasper 6 in the next few months, but I've got to work with this version for now.Let me know if I can provide any additional code snippets.Any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
Solution Tom C Posted April 21, 2015 Solution Share Posted April 21, 2015 Make sure your text field has enough height and width to contain at least one character of your font size - if you cannot see a single field content (such as a $ sign) displayed in the report designer, your field height is not large enough. In your case, increase the height to 20 or decrease font size will fix the problem and allow total page count display in the report page footer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now