jwindberg Posted December 7, 2006 Posted December 7, 2006 How do I get a print when for the last page? This works fine for the first page, but PAGE_NUMBER is not evaluated for both page and report at the same time. new Boolean($V{PAGE_NUMBER}.intValue()==1) I need something like: new Boolean($V{PAGE_NUMBER}.intValue()==$V{PAGES_IN_REPORT})
jwindberg Posted December 7, 2006 Author Posted December 7, 2006 Just in case anyone wants to know why I need this. Automatic paper folders that take printed items and fold them into envelopes specify that there are bars printed on the right edge of the form, about midway down.I was hoping to place them on the background band.If the report is one page, then there are two bars. If it is more than one page, there is one bar per page until the last page, where there are two bars. Thus I had planned on putting on bar on the report in the background, and a second bar below it, and tagging it with a print when that was "print on last page". So, I really need print on last page.. Help!!!!!
lucianc Posted December 8, 2006 Posted December 8, 2006 You can achieve this using the "Auto" evaluation type. You basically need to compare the current page number against the total page number, which is only known when the report generation completes. Since the "Auto" evaluation type decides when to evaluate a variable based on its reset type, you will need to copy the PAGE_NUMBER value into a variable that has "Page" reset type. This variable will be evaluated as the current page number, while PAGE_NUMBER will be evaluated to the total page number. You will have something likeCode:<variable name="currentPage" class="java.lang.Integer" resetType="Page"> <variableExpression>$V{PAGE_NUMBER}</variableExpression></variable>..<background> .. <image evaluationTime="Auto"><imageExpression>$V{currentPage}.equals($V{PAGE_NUMBER}) ? your_image : null</imageExpression> </image> ..</background> HTH,Lucian
DMA02 Posted December 8, 2006 Posted December 8, 2006 I had a similar problem where I had to print something on the last page only. Do an evaluation checking if the current page number variable is equal to the total page count. Make sure the evaluation time is at Report time. That'll make it so that the variable is taken at the end. Plus doing some tests with the evaluation times will help you a lot! And using those Summary and Last Page Footer bands as well. Like the summary band will always be at the end so thats good for something.
jwindberg Posted December 9, 2006 Author Posted December 9, 2006 There's the trick.There does not seem to be a way to know the current page and the total page count at the same time.There is one variable, PAGE_NUMBER, which is evaluated either at "NOW" or at "REPORT", but you can't know both at the same time.
jwindberg Posted December 9, 2006 Author Posted December 9, 2006 That looks close to what I need, but I failed to explain that I was trying to do this with a line.How do I specify evaluationTime="Auto" on a line? <variable name="CURRENT_PAGE" class="java.lang.Integer" resetType="Page" calculation="Nothing"> <variableExpression><![CDATA[$V{PAGE_NUMBER}]]></variableExpression></variable> <line direction="TopDown"><reportElement x="565" y="390" width="29" height="0" key="line-14"> <printWhenExpression><![CDATA[new Boolean($V{CURRENT_PAGE}.equals($V{PAGE_NUMBER}))]]></printWhenExpression></reportElement><graphicElement stretchType="NoStretch" pen="2Point"/></line>
jwindberg Posted December 9, 2006 Author Posted December 9, 2006 For that matter...What the heck does evaulationTime="Auto" mean? It's not in my book, "Jasper Reports for Java Developers". It seems to be capable of comparing now to then, but how does it know what I intend. It works, that's cool, but such black magic scares me so.
lucianc Posted December 12, 2006 Posted December 12, 2006 You can find here a brief description of the "Auto" evaluation feature. Regarding the implementation, it's not exactly magic: the values of the expression participants (fields, variables) are kept in the report element until all the values are available, and at that moment the expression gets evaluated using the saved values. This is only applicable to expressions that can have delayed evaluation, and unfortunately the report element "print when" expressions are not among these. Therefore you will not be able to use "Auto" evaluation to decide whether to print a line or not. Still, the image source expression can have delayed evaluation and you can use an image to "simulate" a line that only prints on the last page. Regards,Lucian
jwindberg Posted December 13, 2006 Author Posted December 13, 2006 The mere placement of <variable name="CURRENT_PAGE" class="java.lang.Integer" resetType="Page" calculation="Nothing"> <variableExpression>$V{PAGE_NUMBER}</variableExpression> </variable> in my template causes things in the header, footer, and intro to vanish. I take it out, and the report works again.
jwindberg Posted December 13, 2006 Author Posted December 13, 2006 damn damn damn damn on a report where the last page only gets a summary, this trick fails.If I use the lastPageFooter, that fails as well.The lastPageFooter prints on the second to the last page, while the summary prints on the last page.The mark I'm trying to put on the last page is for an automatic folder. The mark MUST be on the last page, and it must be in the same postition on the page as it is everywhere else on the report.
Teodor Danciu Posted December 14, 2006 Posted December 14, 2006 Hi, The summary sections is special because it does not get accompanied by the page header or footer (some people want it to behave like this).What you need is to simulate the summary sections as explained here:http://jasperforge.org/sf/wiki/do/viewPage/projects.jasperreports/wiki/FAQ12 If you do so, the lastPageFooter would really be on the last page and you could even place elements at a negative Y on that last page footer so that they appear higher on the page. I hope this helps.Teodor
jwindberg Posted December 15, 2006 Author Posted December 15, 2006 what section would you use for totals at the end of the detail area if not summary?
bwestendorf Posted February 27, 2009 Posted February 27, 2009 Hello... I am having similar issues. I am trying to print something in the Page Footer only on the last page. I have three fields in the last page... two text fields and the page number. I'd like the two text fields to only print on the last page.I've tried a variety of things with no luck... setting the current page and last page... then printing when they equal. Also, setting a isLastPage boolean and checking that... so far no luck.Can anyone please help and/or is there an example somewhere?
Teodor Danciu Posted March 2, 2009 Posted March 2, 2009 Brian, If you have the same problem, you must use the same solution.We've already mentioned the lastPageFooter section. Did you use it? Also, I have indicated that the footer section of a dummy group that has no group expression could be used as summary, in case the true <summary> section does not work as expected (but John ignored my solution and asked again what section he should use). I hope this helps.Teodor
nnvc Posted October 16, 2009 Posted October 16, 2009 Hi,I have a chart in the summary band, how can i solve the same problem of page footer?i have tried it with the last page footes, but it didnt work.i hope someone can help methanks
yukini Posted November 25, 2009 Posted November 25, 2009 Hi,I am not able to use that link to the FAQ's. I also tried that method to put the elements to last page footer section and put a negative y for a different position, but they won't get printed. Urgent, need help.
Teodor Danciu Posted November 25, 2009 Posted November 25, 2009 Hi, Please do not post more replies to this thread. The original thread is from 2006 and many things have happened since.The FAQs were moved here:http://jasperforge.org/website/jasperreportswebsite/trunk/faq.html New features were added to the engine, including the isSummaryWithPageHeaderAndFooter option. Please create a new thread for your problem and try explain it the best you can, providing screenshot and sample files if possible. Thank you,Teodor
gbisogno Posted February 19, 2010 Posted February 19, 2010 I use a similar solution but for show a variable in the last page. In addition check "Blank when null" for the text field. Regards.German
srins.9 Posted November 29, 2017 Posted November 29, 2017 Have a variable like currentPage<variable name="currentPage" class="java.lang.Integer" resetType="Page"> <variableExpression><![CDATA[$V{PAGE_NUMBER}]]></variableExpression> </variable>for a field to print only on last page have expression like $V{currentPage}.equals( $V{PAGE_NUMBER} ) ? $F{fieldName} : ""and set evaluation time = Auto
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