Table header/footer problem

View: New views
6 Messages — Rating Filter:   Alert me  

Table header/footer problem

by poncke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I have a problem generating a document with page headers/footer. The document is one big table.
I dont need the default style page headers/footers (I looked at page events already) that are always placed at the top/bottom of a page but table based that are added at the top/bottom of the report table (only on page if table spans multiple pages).

Example document structure as visible in pdf viewer:

        Document Header (Only on first page)
        Document Page Header (Every page except the first)
                Report Page Header (Every page)
                Report Data
                Report Page Footer (Every page)
        Document Page Footer (Every page except the last)
        Document Footer (Only on last page)

All parts need to fit tightly together so no spacing between the parts (so the page footer for the last page can be in the middle of the page depending on the size of  the report)
I tried 3 ways to accomplish this but each one failed.
What I basically need is the result of test2 but seamless.

Sample source: Main.java

1)
Use separate tables for the document header and document footer and add the document page headers/footers to the report table
Problems with test1:
- The report header/footer is also excluded the first/last page
- The page/report footer on the first page are to low (even go off page if more footer rows are added)
- The document footer table on last page is to low (seems like the space for the skipped footers is still used while they are not rendered)
test1.pdf

2)
Use separate tables for the document header and document footer.
Use new table for document page header/footer and report, report is embedded in this table and has its own page headers/footers.
Problems with test2:
- The document header is on the first page while the rest of the report starts on the second page
- the document footer table on the last page is to low (same as in test 1)
test2.pdf

3)
Use separate tables for the document header and document footer
Use new table for document page header/footer and report, report is embedded in this table and has its own page headers/footers.
Ad the above 3 tables to a new layout table and add that to the document.
Problems with test3:
- Same as test2
test3.pdf

Re: Table header/footer problem

by mister bean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Strictly speaking, this requirement cannot be met using page events:

"All parts need to fit tightly together so no spacing between the parts (so the page footer for the last page can be in the middle of the page depending on the size of  the report)"

Page events, which trigger the printing of headers and footers, occur only at the end of the page, not in the middle. This is, of course, why they're called headers/footers, as I suspect you know.

If you can let go of that requirement, then:

In your shoes, I would make a header/footer table with two rows and move the lines of text in and out (and move them up when there's only one line) depending on where you are in the document.

Finally, you should note that if you look at the code for implementing footers and headers, you're running pretty close to the metal, well paper ;-) You can emit the correct text yourself rather than depending on iText to do the work for you. That option will require some study of how iText is implemented.

---mr. bean

>>>


poncke wrote:
Hello,

I have a problem generating a document with page headers/footer. The document is one big table.
I dont need the default style page headers/footers (I looked at page events already) that are always placed at the top/bottom of a page but table based that are added at the top/bottom of the report table (only on page if table spans multiple pages).

Example document structure as visible in pdf viewer:

        Document Header (Only on first page)
        Document Page Header (Every page except the first)
                Report Page Header (Every page)
                Report Data
                Report Page Footer (Every page)
        Document Page Footer (Every page except the last)
        Document Footer (Only on last page)

All parts need to fit tightly together so no spacing between the parts (so the page footer for the last page can be in the middle of the page depending on the size of  the report)
I tried 3 ways to accomplish this but each one failed.
What I basically need is the result of test2 but seamless.

Sample source: Main.java

1)
Use separate tables for the document header and document footer and add the document page headers/footers to the report table
Problems with test1:
- The report header/footer is also excluded the first/last page
- The page/report footer on the first page are to low (even go off page if more footer rows are added)
- The document footer table on last page is to low (seems like the space for the skipped footers is still used while they are not rendered)
test1.pdf

2)
Use separate tables for the document header and document footer.
Use new table for document page header/footer and report, report is embedded in this table and has its own page headers/footers.
Problems with test2:
- The document header is on the first page while the rest of the report starts on the second page
- the document footer table on the last page is to low (same as in test 1)
test2.pdf

3)
Use separate tables for the document header and document footer
Use new table for document page header/footer and report, report is embedded in this table and has its own page headers/footers.
Ad the above 3 tables to a new layout table and add that to the document.
Problems with test3:
- Same as test2
test3.pdf

Re: Table header/footer problem

by poncke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the reply

I know I can't use page events as I said :)

I basically demonstrate what I think are several a bugs in the PdfPTable implementation (the incorrect spacing that occurs as explained and demonstrated below).

The demonstration code is just that, to demonstrate the problem. The content of the "real" report will be more complex (with headers containing nested tables with images/rowspan/colspan etc).

I'm indeed looking at the option to do all rendering myself. I "suspect" that this is what PdfPTable already does for us and that this is incomplete (ie work in progress) causing the demonstrated bugs.
But i'd rather have PdfPTable work correctly as a more durable solution.


Strictly speaking, this requirement cannot be met using page events:

"All parts need to fit tightly together so no spacing between the parts (so the page footer for the last page can be in the middle of the page depending on the size of  the report)"

Page events, which trigger the printing of headers and footers, occur only at the end of the page, not in the middle. This is, of course, why they're called headers/footers, as I suspect you know.

If you can let go of that requirement, then:

In your shoes, I would make a header/footer table with two rows and move the lines of text in and out (and move them up when there's only one line) depending on where you are in the document.

Finally, you should note that if you look at the code for implementing footers and headers, you're running pretty close to the metal, well paper ;-) You can emit the correct text yourself rather than depending on iText to do the work for you. That option will require some study of how iText is implemented.

---mr. bean

>>>


poncke wrote:
Hello,

I have a problem generating a document with page headers/footer. The document is one big table.
I dont need the default style page headers/footers (I looked at page events already) that are always placed at the top/bottom of a page but table based that are added at the top/bottom of the report table (only on page if table spans multiple pages).

Example document structure as visible in pdf viewer:

        Document Header (Only on first page)
        Document Page Header (Every page except the first)
                Report Page Header (Every page)
                Report Data
                Report Page Footer (Every page)
        Document Page Footer (Every page except the last)
        Document Footer (Only on last page)

All parts need to fit tightly together so no spacing between the parts (so the page footer for the last page can be in the middle of the page depending on the size of  the report)
I tried 3 ways to accomplish this but each one failed.
What I basically need is the result of test2 but seamless.

Sample source: Main.java

1)
Use separate tables for the document header and document footer and add the document page headers/footers to the report table
Problems with test1:
- The report header/footer is also excluded the first/last page
- The page/report footer on the first page are to low (even go off page if more footer rows are added)
- The document footer table on last page is to low (seems like the space for the skipped footers is still used while they are not rendered)
test1.pdf

2)
Use separate tables for the document header and document footer.
Use new table for document page header/footer and report, report is embedded in this table and has its own page headers/footers.
Problems with test2:
- The document header is on the first page while the rest of the report starts on the second page
- the document footer table on the last page is to low (same as in test 1)
test2.pdf

3)
Use separate tables for the document header and document footer
Use new table for document page header/footer and report, report is embedded in this table and has its own page headers/footers.
Ad the above 3 tables to a new layout table and add that to the document.
Problems with test3:
- Same as test2
test3.pdf


Parent Message unknown Re: Table header/footer problem

by Kevin Brown-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For a document this complex, you may want to consider using XSL FO. This
type of structure is trivial as it is what XSL FO was designed to do.

It is a page-sequence with different repeatable alternatives (layouts) for
first, last and rest (middle) that contains a table with a table-header and
table-footer.

Kevin Brown

poncke wrote:

> Hello,
>
> I have a problem generating a document with page headers/footer. The
> document is one big table.
> I dont need the default style page headers/footers (I looked at page
> events already) that are always placed at the top/bottom of a page but
> table based that are added at the top/bottom of the report table (only
> on page if table spans multiple pages).
>
> Example document structure as visible in pdf viewer:
>
> Document Header (Only on first page)
> Document Page Header (Every page except the first)
> Report Page Header (Every page)
> Report Data
> Report Page Footer (Every page)
> Document Page Footer (Every page except the last)
> Document Footer (Only on last page)
>
> All parts need to fit tightly together so no spacing between the parts
> (so the page footer for the last page can be in the middle of the page
> depending on the size of  the report) I tried 3 ways to accomplish
> this but each one failed.
> What I basically need is the result of test2 but seamless.



------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: Table header/footer problem

by 1T3XT info :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

poncke wrote:
> I basically demonstrate what I think are several a bugs in the PdfPTable
> implementation (the incorrect spacing that occurs as explained and
> demonstrated below).

I'm sorry, I failed to see any bugs; I only saw "wrong use of iText".
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: Table header/footer problem

by poncke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, XSL-FO indeed looks more fitting to what I want to achieve.

Kevin Brown-9 wrote:
For a document this complex, you may want to consider using XSL FO. This
type of structure is trivial as it is what XSL FO was designed to do.

It is a page-sequence with different repeatable alternatives (layouts) for
first, last and rest (middle) that contains a table with a table-header and
table-footer.

Kevin Brown

poncke wrote:

> Hello,
>
> I have a problem generating a document with page headers/footer. The
> document is one big table.
> I dont need the default style page headers/footers (I looked at page
> events already) that are always placed at the top/bottom of a page but
> table based that are added at the top/bottom of the report table (only
> on page if table spans multiple pages).
>
> Example document structure as visible in pdf viewer:
>
> Document Header (Only on first page)
> Document Page Header (Every page except the first)
> Report Page Header (Every page)
> Report Data
> Report Page Footer (Every page)
> Document Page Footer (Every page except the last)
> Document Footer (Only on last page)
>
> All parts need to fit tightly together so no spacing between the parts
> (so the page footer for the last page can be in the middle of the page
> depending on the size of  the report) I tried 3 ways to accomplish
> this but each one failed.
> What I basically need is the result of test2 but seamless.



------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/