Soviut Soviut - 11 months ago 140
Python Question

How to vertically align Paragraphs within a Table using Reportlab?

I'm using Reportlab to generate report cards. The report cards are basically one big Table object. Some of the content in the table cells needs to wrap, specifically titles and comments, and I also need to bold certain elements.

To accomplish both the wrapping and ability to bold, I'm using Paragraph objects within the Table. My table needs several of these elements vertically aligned to 'middle' but the Paragraph alignment and snaps my text to the bottom of the cell.

How can I vertically align my Paragraph within a Table cell?

Answer Source

I have to ask: have you tried the tablestyle VALIGN:MIDDLE?

something like:


(more details in section 7.2 of the ReportLab user guide)

If that doesn't do it, then your paragraph object must be the full height of the cell, and internally aligned to the bottom.

Could you please post a small sample that reproduces the problem?