Any idea on how to add a blank page at the end of a report?

0

Hi community.

I'm not new to jasperreport but I'm getting mad to find a solution to the following problem:

- the report is a tipical invoice with head, title, detail, footer, summary, etc.

- the report/invioce can have N pages

- if and only if the total number of the pages is odd I need to add at the end a completely blank page (the format is A4)

I tried to search using "last blank page" or "blank page" or "blank page at the end" and so on but nothing related to this specific problem.

Have anyone ever had and solved (of course) a such problem?

Do you have any suggestion?

Thanks in advance.

carlo.traversa's picture
Joined: Jul 3 2018 - 5:16am
Last seen: 1 year 4 months ago

5 Answers:

0

Haven't tried this myself but have you tried putting a "Break" element in the Summary band with "Print When Expression" condition based on whether the page count is even or not?

hozawa's picture
53300
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 2 weeks ago
0

Hi hozawa.

Thank you very much for your answer. Your suggestion worked perfectly. I put in the report a break element in the summary with the condition:

$V{PAGE_NUMBER}.intValue()%2!=0

In this way ONLY if the last page is odd I get an "almost" blank page.

Almost because with your suggestion I solved the 99% of the problem.

The last 1% of the issue is that in the report I use backgroud band to render vertical lines for report column.

So I'd need a way to say the report to NOT print vertical lines in the last page of the report and only if the last page is odd.

The condition "page odd" is easy. The condition "last page of the report" seems to be impossible to solve (I google it a lot also on the forum).

I could solve it if in jasper report there was the possibility to know at the beginning of the report the total number of pages (let's say TOTAL_PAGE_NUMBER) and create a "print when expression" like the following to apply to the vertical lines:

(  $V{PAGE_NUMBER}<$V{TOTAL_PAGE_NUMBER} ? newBoolean(true) : newBoolean(false) )

Any idea or workaround to solve this last problem? Any help is appreciated.

Thank you very much.

carlo.traversa's picture
Joined: Jul 3 2018 - 5:16am
Last seen: 1 year 4 months ago
0

For variable $V{PAGE_NUMBER}:

  - Set the [Evaluation Time] to [Report] to get the total pages

   - Set the [Evaluation Time] to [Now] to get current page

riodavid's picture
507
Joined: Oct 27 2016 - 1:57am
Last seen: 1 year 2 weeks ago
0

Hi riodavid.

Thank you for you suggestion. It wouldn't work because I'd need to use the variable $V{PAGE_NUMBER} in the "Print when expression".

When you use the variable $V{PAGE_NUMBER} to check its value in the "Print when expression", there is no way to specify [Evaluation Time] to [Report] or [Evaluation Time] to [Now] .

The value of the variable $V{PAGE_NUMBER} in the "Print when expression" is always the current page number and nothingelse.

Anyway thank you for you reply.

 

carlo.traversa's picture
Joined: Jul 3 2018 - 5:16am
Last seen: 1 year 4 months ago
0

You are right. This is hard to achieve. Someone asked this question in 2007 and still no valid answers.

https://community.jaspersoft.com/questions/515587/how-know-total-pages-r...

riodavid's picture
507
Joined: Oct 27 2016 - 1:57am
Last seen: 1 year 2 weeks ago
Feedback