How do I set textfield and image only on last page in Jasper Reports? [duplicate] - jasper-reports

This question already has answers here:
Compare current page number with last page number
(3 answers)
Using Print When Expression in the last page of report
(1 answer)
Closed 12 months ago.
I have a report with several pages, and I have some Group/Bands with 'Reset Page Number' activated. I hope the picture below can illustrate it much better.
All these 5 pages are the result of 1 JasperReport. The page numbers are grouped for each specific header, and reseted when a new header starts. I need to add some images and textfields only on the last page (see the picture).
My Problem is that I dont know how. I've tried to use an if/else condition (on the summary Group/Band) inside the image and the textfield. When the current pages is equal to the total number of pages.
But that doesnt work because of the reseting of the page numbers (so far my understanding).
I've tried also the master and custom variables(who count the pages), the master variables also get a reset after the groups, so the current page is never up to the total page number.
With the custom variables I can't create two variables (one who counts current page, the other who counts the total pages) inside one textfield/image because of different evaulation times.
Following is an example of the if/else condition which I tried to use in the textfield/image:
$V{VAR_TOTAL_PAGE_NUMBER} == $V{VAR_PAGE_NUMBER} ? "custom text/image" : null
Here are the code for the VAR_PAGE_NUMBER/VAR_TOTAL_PAGE_NUMBER:
<variable name="VAR_PAGE_NUMBER" class="java.lang.Integer" incrementType="Page" calculation="Count">
<variableExpression><![CDATA[$V{VAR_PAGE_NUMBER}]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
I know they are both the same, so far I realized the difference with the evaluation time, but I don't know how to let 1 Varaible count every page while the other counts the total with the same evaluation time.

Related

How to hide/show and image or textField on last page?

In Jasper studio how can I disable/show background for a single page in the report.
I want to disable the watermark image which I set in the background for the last page.
The simplest method that I know when you need to compare current page towards totale number of pages is to use evaluation type "auto" on the element.
From EvaluationTimeEnum
Variables will be evaluated at a time corresponding to their reset type.
Solution adapted from lucianc's answer at https://community.jaspersoft.com/questions/514622/print-when-last-page
Create a variabile that contains current page having reset type Page (so it's evaluate when Auto as current page number)
<variable name="currentPageInAutoEval" class="java.lang.Integer" resetType="Page">
<variableExpression>$V{PAGE_NUMBER}</variableExpression>
</variable
set evaluation time to "Auto" on your element (textField, image etc) and in expression use ternary operator
In your case, no image on last page it would be
<image evaluationTime="Auto">
<imageExpression>$V{currentPageInAutoEval}.equals($V{PAGE_NUMBER}) ? null : yourImage</imageExpression>
</image>
Hence with evalutationTime="Auto" $V{currentPageInAutoEval} will be evaluated as resetType (Page) to current page number and $V{PAGE_NUMBER} as the total number of pages.

Fix Page Header Height in Crystal reports

Is it possible to fix the height of page header or any other solutions?
My problem is I need to do this list of persons in page header
Boy Janna
Girl Leo
Ana Erick
Mina Carlo
Lea Shena
But it must be like this
(for page 1)
Boy Janna
Girl Leo
Ana Erick
(next page)
Mina Carlo
Lea Shena
If number of person is 6 or lower it will only appear in first page (if two page report the second page must have blank person). If the number of person is more than 6 the number 7 person and up will appear to next pages and so on.
The maximum row is 3 per page
This Sub report is in Page header in main report
I put this code in supress of Sub Report for Persons. If I don't tick the Can Grow and adjust the text box (it only shows 6 names) and other names are now missing and not appearing in the next page. If I tick can grow and remove the below supression code what happens is it shows repeated name each page.
if PageNumber = 1 then
false
else if PageNumber = TotalPageCount then
true
else
true
Thanks in advance
yes you can do it in group header or footer and the process you followed won't give you correct results. Follow below process.
In grouper header or footer take a sub report and place only those fields in the sub report that you want to display.
In sub report place the field in detail section and then go to
Right click Details --> section expert --> paging --> tick the check box visible records
In the space provided input number of records you want to view per page and no go to preview.
You can see those many records per page in group.
This is working solution I tried group header and group footer of a group.
Let me know if you face any issue.

Footer printed when page number is pair. Leaves blank space on other pages

I'm having some issues with JasperReports. I have a page footer that only prints when $V{PAGE_NUMBER}.intValue() % 2 == 0 .
This works correctly, but the main issue is that the page footer always occupies its fixed height, wether it is printed or not.
This behaviour makes me really sad, because my boss wants "these to be done well and for yesterday", but that extra space on unpair pages is making my reports not really very good looking: my page footer is really tall (height of 200px, more or less) and the blank space it leaves on odd pages is too big.
I tried almost everything I could read regarding this issue, but couldn't find a solution. I tried to move the contents of the page footer to a detail band and try to print that band at the bottom of the page when the page number is odd, but this solution didn't really work.
I would appreciate any kind of help. Please reply or my boss kills me.
The pageFooter and columnFooter are bands that do not allow overflow, the report engine calculates there size not on content but on band height which means that they will always be present with the band height you set...
Quoting Teodord jasper report staff
"I'm afraid there is no solution for what you want to achive"
This is in fact why jasper report introduced lastPageFooter, to enable the possibility to have a footer only on last page. Furthermore there was a feature request for firstPageFooter.
But it has been closed, no changes required, use negative coordinates, background band...
Conclusion:
You need to re-think you report structure, is there any logical grouping on which you can add a groupFooter you can stack it to the bottom footerPosition="StackAtBottom", or leave it as it is and go home ; )
Don't try to foul jasper report by grouping on $V{PAGE_NUMBER}.intValue() % 2 == 0, unfortunately it will not work..., you need to find
a logical grouping within your fields (data) or
on the number of records present in page $V{PAGE_COUNT}>20 or
something like $V{PAGE_COUNT}>15 || ($V{PAGE_NUMBER}%2==0 && $V{PAGE_COUNT}>10) that actually works breaking differently every odd page, leaving you the space after 15,10 records.. (note space is not really controlled if you isStretchWithOverflow="true" on the textField in detail band)
so go home....

Crystal Reports multiple parameter screens

I am creating a report with crystal reports 2008. My report has 4 parameters that the user must input, lets say: var1, var2, var3, var4. When I open the report it brings up the prompt to enter var1, once entered the user clicks next, and it goes to a second screen to get the next parameter, and so on.
My question is, is there a way to combine all of these to one screen. When the report opens, it has 4 drop downs for the parameters instead of one at a time?
I have thought about (and tried) a parameter that accepts multiple values but could not get it to work for my purposes. I am displaying approx 6 fields related to each parameter selected. SO if var1 is entered there will be 6 additional fields displayed. If it is not selected the area remains empty. Essentially each parameter represents a column to display in the report.
If there is a way to combine the 4 parameter screens that would be great, if you think this can be done using a multi value parameter then that is all I need to know and I will keep at it.
Thank you
Probably did not go about this in the best way but it serves its purpose and thought I would share for future reference. In response to the comments above, the parameters are not linked and I was not using a sub-report.
I ended up splitting the GroupSectionHEader into 4 parts, one for each variable. The report not contained GroupSectonHeader1-5. Each parameter variable had its own section. The user could select the parameter or False from the parameter input dialog. I then used the section expert and for each Group Header in the formula box nex to Suppress (No-Drill-Down) entered isnull({#var#}) or {var#} = " " this is because my variables are strings. This way if the user chose False, the variable would be left black and this formula would pick up on that and hide that section in the final formula.
I am very new at CR so I doubt my explanation is as clear as it could be, nor the most proficient.

Issue regarding subreprt in active report 7

I want display records in the active reports 7 as 4 record in one page and information that record in the next page?So,I what should use do that?I have tried sub-report and page break but that doesn't work?
Is there any other way to use sub report or any other thing that we can use.
As far my understanding of the issue goes, you want to show 4 records on a page and then show the remaining data on the new page. There isn't any direct way to achieve this.
However a workaround for you is to make use of the If-else loop in the Detail's Format event. Add a counter in the Detail's Format event and when it reaches '4', set the NewPage property of Detail Section to 'After' under the 'If' condition and under the 'Else' part reset the NewPage property of Detail Section to 'None'. 
Please share your observations with us.
Regards,
Mohita