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

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.

Related

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

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.

iReport - How to prevent texfield go to next page

I need help!
When Textfield Text is too big and does not fit all the content on the page, it is automatically moved to the next page, can anyone help?
The result is the following:
The structure of the report is as follows:
structure of the report
The expected result would be to completely fill the first page, and then break to next.
You can manage your detail band selecting it and change the property Split type as the following image:
The meanings of three options:
STRETCH:
The band is allowed to split, but never within its declared height. This means the band splits only when its content stretches.
PREVENT:
Prevents the band from splitting on first break attempt. On subsequent pages/columns, the band is allowed to split, to avoid infinite loops.
IMMEDIATE:
The band is allowed to split anywhere, as early as needed, but not before at least one element being printed on the current page/column.
You can see here

Document band Occupying white space when not printed

I need to print a set of information on the bottom of my document's first page (right after detail band). Since the information printed on detail is too large, the document creates a pagination to display the rest of the information, but independent of what I use (Group,ColumnFooter,PageFooter,etc) to print the information tha should be printed on the first page only, this band keeps occupying a white space on consequent pages.
You can create a dummy group that would break with every record, but only while we are on the first page.
Such group would not have a group header or footer, but would use minHeightToStartNewPage with a value that would match the taller page footer required on the first page.
The group expression would look like the following:
$V{PAGE_NUMBER} == 1 ? $V{REPORT_COUNT} : null
This dummy group would cause a page break to occur upper on the first page, leaving more space for a larger page footer.
Now, the second trick is to place content in the page footer section, but at a position having a negative Y coordinate. By doing so, you can keep the height of the page footer section small, while being able to render content above it.
This content having negative Y inside the page footer would be printed conditionally, only on the first page, using the printWhenExpression.

How to give expression for the details band based on the return value from subreport of the same band?

I am using iReports 4.7.1
I have 2 sub reports in my main report and they are in saperate bands. I need to hide the band if sub report returns no rows. I am able to get subreport value in my main report. But if i use that variable as a expression in the same band the value of that variable is becoming null, If i use that same variable in other details band, it is not becoming null.
I have two question to ask,
Why the value is becoming null if i use in same band?
Is their any other way to hide subreport returns no rows?
I followed this steps to create variable and return value from subreport to main report.
And also i tried this new Boolean($V{SUB_REPORT_ROW_CNT}.intValue()!=0) or $V{SUB_REPORT_ROW_CNT} != null expression in print when expression for the band.
Why the value is becoming null if i use in same band?
I need to see jrxml but probably you do not have correct EvaluationTime on the textField, try to set Band or Report example evaluationTime="Report" on the textField.
Is their any other way to hide subreport returns no rows?
The normal way to remove an empty subreport is by setting isRemoveLineWhenBlank="true" on the reportElement of the subreport.
Make sure your subreport return no page (empty) when no data by setting the whenNoDataType="NoPages" (or removing this attribute since this default) on the jasperReport tag
This will remove the subreport, note however if you like text under it to move you need to set positionType="Float", otherwise they will remain where they are since default is positionType="FixRelativeToTop"

New page in iReport

this is my situation:
I have a report with 10 (or more) items in detail area
I have a large text field that I would like to span across multiple pages (this text has nothing to do with items)
I am not able to create another page because all of my items fit nicely on the first page
How can I create (force) a new page to contain only some variable (static) text, on the page footer? In other words, how can I create a new page with no items?
In iReport Designer 4.1.1
The Break element is inside the Palette window.
You can select if you want to break the page or column
Palette > Report Elements > Break -> Page break.
Everything what is after this Break is printed on next Page.
Can you be specific about iReport version.
In 2.0.5, from the Edit menu choose "Insert page/column break"
Put it in the band where you want to break. In the Properties dialog, make sure the Break Type is set to "Page"
I usually prefer to use it with "Print with expression" so it does not make an empty page when i dont have an empty report already.
In 5.5.0
You can add large text field to the Summary band.
Then,click report name in Report Inspector find "Summary on new page" in Properties then check.
So you have new page after detail.
You can increase the page size of detail band in Ireport, To increase size go to xml tab
and search for
<detail>
<band height="482"/>
and add
<detail>
<band height="600" splitType="Immediate">
After that i think you may able to see another page.I have tested this method with only Summary band, if it does not work copy all the item in summary band.
You can use Break that you will get from Palette.
And if you want to add some text in the footer of second page only then you can't do it with the Brak only.
In that situation you need to use PrintWhen expression suits for your requirement.