Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Height of a table on reportlab canvas

I am drawing a table on reportlab canvas. While drawing, we need to pass bottom left coords of the table to the drawOn method. The height of my table is dynamic and therefore it overlaps on the elements above the table. I couldnot find any method that returns the height of a table that is to be drawn. Is there an alternate way to do that?

like image 912
Aman Avatar asked Oct 16 '12 17:10

Aman


1 Answers

This is such a simple thing that is passively demonstrated but not explicitly addressed in the reportlab documentation:

t = Table(tableData, style=tStyle)
t.canv = myCanvas
w, h = t.wrap(0, 0)

The variables w and h will then store the table's width and height, respectively.

like image 55
Tom Avatar answered Oct 07 '22 09:10

Tom