[reportlab-users] How to make a table with rows longer than one page in raportlab for Lea Kaminski

Maxim Danilov info at twinboards.at
Wed Jan 9 07:07:28 EST 2019


Hello Leo.
Please, don’t please do not listen Voices from Peoples, who can not normal work with ReportLab.

For example: "Robin Becker says 'we have never supported splitting cells so there's no obvious answer.’
Not correct! 

Right answer:
it,s easy, and every should use it, for good work with PDF-generator. 

every BaseDocTemplate has “handle_flowable(self, flowables)”
In this function you can check for every PDF-object width and height.
____________________________
width, height = flowables[0].wrapOn(self.canv, maxW, maxH)
if height > maxH:
	bla bla bla….
________________

if yours table is more than maxHeight and reportlab CANNOT split it right:

in this moment i like to do: canvas.drawtext(‘generator error on table id_num’)
But you can make more, for example:
1. You can found big rows and you can set correctly row.height. that helps get pdf but it can be not correct for big rows.

2. If report lab can not make it correct automatically: You can make for every row in “big_table” one table.
After that you should check:
If new_table_with_only_one_row.height > maxH:

You should found big cells in new_table.data and you can try to split this cell on two or more smaller parts.

Please check if it a SVG picture, you can make it smaller, but you cannot crop it with PIL in python.

After that you can change one_row_table on two_or_more_rows_table, and this Table the report lab can split correct.

You can ask me, if it’s difficult for you.


Sorry, my main language is not Englisch


Mit freundlichen Grüßen,
DI Mag. Maxim Danilov

+43(681)207 447 76
info at twinboards.at

Hi Leo,

we have never supported splitting cells so there's no obvious answer. Simple strings will just overflow across the page if you 
have fixed width columns, but simple strings allow you to count the number of lines. You can put Paragraphs into tables and then 
they will wrap lines so avoiding the simple split code. However we don't have an answer for the case when even wrapped lines 
overflow the page (or frame height).

On 05/01/2019 10:58, Lea Kaminski wrote:
> Hi guys,
> 
> thank you a million times for the last answer. They worked very well. Now i got a new porblem.
> I have a table, where the rows are somethimes longer than one page, and  then the programm crashes. I found some kind of solution on stack overflow (https://stackoverflow.com/questions/3297115/python-reportlab-rml-how-to-split-table-row-on-two-pages <https://stackoverflow.com/questions/3297115/python-reportlab-rml-how-to-split-table-row-on-two-pages>)
> , which i am not able do integrate in my code the right way.
> 
> I would be really glad if someone of you know a solution how i could fix the problem.
> 
> Below the code:
> 
> from reportlab.lib.pagesizes import A4
> from reportlab.lib.pagesizes import letter, cm
...........
> 


-- 
Robin Becker

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20190109/3063bc9d/attachment.html>


More information about the reportlab-users mailing list