Getting Height of a table on reportlab canvas

pdf-generation, python, reportlab

Solution

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.

Problem

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?

Original source