[reportlab-users] Large table with totals in page footer

38 views
Skip to first unread message

Tony Middleton via reportlab-users

unread,
Mar 29, 2017, 9:41:06 AM3/29/17
to reportl...@lists2.reportlab.com, Tony Middleton

I am trying to create a document with a multipage table.  At the bottom of each page I need a footer which includes some information derived from rows printed on that page.  I am using the Table() class and rows are variable height so I don't know which rows will print on a page.

I've looked around and can't find any way to do this.  Any pointers would be greatly appreciated.

Regards

Tony Middleton

Robin Becker

unread,
Mar 29, 2017, 12:07:39 PM3/29/17
to reportlab-users
On 29/03/2017 14:41, Tony Middleton via reportlab-users wrote:
> I am trying to create a document with a multipage table. At the bottom
> of each page I need a footer which includes some information derived
> from rows printed on that page. I am using the Table() class and rows
> are variable height so I don't know which rows will print on a page.

I don't think this can be done terribly easily with the existing table class; a
derived class will be needed, but whether that's from the Table or some element
class included in the rendered rows is hard to say.

Logically if you know the height of the extra information then it seems
reasonable to add something in the split method ie when the table splits some
ectra information can be detected and arrangements made to put that into a
specific location.

>
> I've looked around and can't find any way to do this. Any pointers
> would be greatly appreciated.
>
> Regards
>
> Tony Middleton
..........


--
Robin Becker
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
https://pairlist2.pair.net/mailman/listinfo/reportlab-users

Tony Middleton via reportlab-users

unread,
Mar 31, 2017, 6:29:40 AM3/31/17
to reportlab-users, Tony Middleton
Thank you.  I've now got something working with afterPage and onSplit.  When I have the code tidied up I'll show it here.

However, I do have a complication.  The documents I create will have a table of approx 7000 rows over 600 pages.  I need to introduce page breaks in the table at certain points.  I though there might be a pagebreak command in TableStyle but there isn't.  I got round this initially by splitting the table into multiple tables with PageBreak() between but this messes up my code for page footers.

Is there a way of forcing page break in a single table or do I have to make my code cope with multiple tables?

Regards

Tony


On 29/03/17 17:07, Robin Becker wrote:

Robin Becker

unread,
Mar 31, 2017, 6:51:09 AM3/31/17
to reportlab-users
On 31/03/2017 11:29, Tony Middleton via reportlab-users wrote:
> Thank you. I've now got something working with afterPage and onSplit.
> When I have the code tidied up I'll show it here.
>
> However, I do have a complication. The documents I create will have a
> table of approx 7000 rows over 600 pages. I need to introduce page
> breaks in the table at certain points. I though there might be a
> pagebreak command in TableStyle but there isn't. I got round this
> initially by splitting the table into multiple tables with PageBreak()
> between but this messes up my code for page footers.
>
> Is there a way of forcing page break in a single table or do I have to
> make my code cope with multiple tables?

well done for getting anywhere with this. If you used the split method to grab
your information then it should be possible to also get it to return an extra
item if required ie splitting a table is not required to just return tables.

If the requirement is to auto split in some way then the content of the table
needs to be somewhat active. Putting a PageBreak into a cell isn't going to
work, but making some content force a split might be possible.


>
> Regards
>
> Tony

Tony Middleton via reportlab-users

unread,
Apr 2, 2017, 8:39:14 AM4/2/17
to reportl...@lists2.reportlab.com, Tony Middleton
I've now got a solution to this - example attached.  Thank you to Robin Becker for his help.

To recap, I need to create a document which is one big table approximately 600 pages long.  On the footer of each page I need to include something derived from the rows printed on that page.  I need to include page breaks at certain points;  there doesn't seem to be a way of doing this within a table so my document is a sequence of separate tables which has made the solution more complicated.

The solution isn't terribly elegant but it seems to work.

Regards

Tony Middleton
example.py
Reply all
Reply to author
Forward
0 new messages