Question

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?

Was it helpful?

Solution

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

something like:

t=Table(data) 
t.setStyle(TableStyle([('VALIGN',(-1,-1),(-1,-1),'MIDDLE')])) 

(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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top