Jump to content
Changes to the Jaspersoft community edition download ×

How to output to bottom last page only ?


Recommended Posts

By: Albert L. - looks

How to output to bottom last page only ?

2002-11-27 11:29

I have the following report :

- Simple Master-Detail structure.

- Each new Master (document) starts on a new page.

- Page number is reset, for every new document.

 

Example :

------------------

New page

Document A

Detail ...

...

...

Detail ...

----------

Total

----------

Signature

Page number

 

New page

Document B

Detail ...

...

Detail ...

----------

Total

----------

Signature

Page number

------------------

 

All is working fine and the table structure is simple

enough to be passed by a single query result set.

 

However, the tricky bit is the position of the Signature

area. It must be located at the bottom of every last page

for each document.

 

GroupFooter (where total is placed) cannot be used,

as it's position depends on the number of details

within the document.

 

Summary section also cannot be used, as it appeared

only once, at the very end of the report.

 

I've tried PageFooter, using printWhenExpression, but

don't seems to get the correct expression for it to

only print on the last page of each document.

 

Sub report will probably handle that, by printing

a new sub-report per new document and putting the

signature area in summary section, but the report

structure is simply too simple to warrant sub-report

usage.

 

Thanks in advanced.

 

Albert.

 

 

By: Teodor Danciu - teodord

RE: How to output to bottom last page only ?

2002-12-08 23:20

 

Hi,

 

Here's what you could do:

 

Place your signature on the page footer.

But devise a way to know exactly that the current

page is the last page of your current document.

This is not too difficult.

In fact, the last page is always the one that displays

the group footer, right?

So, you could place a hidden element on this group footer

and use its "printWhenExpression" to simply set a flag somewhere

that would indicate to the page footer that it is the time

for him to display the signature on the current page.

 

1. Define this variable into your report:

 

<variable name="FlagsMap" class="java.lang.Object" resetType="Report" calculation="System">

<initialValueExpression>new java.util.HashMap()</initialValueExpression>

</variable>

 

2. Put this line as the first element on your group footer section:

 

<line>

<reportElement x="0" y="0" width="0" height="0">

<printWhenExpression>

((java.util.Map)$V{FlagsMap}).put("IS_PRINT_SIGNATURE", Boolean.TRUE)

</printWhenExpression>

</reportElement>

</line>

 

3. Put this "printWhenExpression" in your signature element on the page footer:

 

<printWhenExpression>

((java.util.Map)$V{FlagsMap}).get("IS_PRINT_SIGNATURE")

</printWhenExpression>

 

4. The next element in the page footer should be this line (after the signature):

 

<line>

<reportElement x="0" y="0" width="0" height="0">

<printWhenExpression>

((java.util.Map)$V{FlagsMap}).put("IS_PRINT_SIGNATURE", Boolean.FALSE)

</printWhenExpression>

</reportElement>

</line>

 

 

One disadvantage of this is that you will have some white space

where the signature should be, when it does not print.

 

You can eliminate this if you use a negative Y for the signature

so that it apears further up on the last page, without having to

set a tall page footer (ignore the compile time warning).

But when the details will run to the bottom of the page,

the signature might overlap them.

 

When you'll master JasperReports, I'm sure you'll find better solutions.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...