[reportlab-users] Paragraphs and Tables

Farshid Lashkari flashk at gmail.com
Fri Jan 19 13:50:20 EST 2007


Hi,

I just started using reportlab and it is really cool to work with. I
was able to accomplish almost everything I needed within a couple
hours. I have one problem though.

When I insert a Paragraph into a table cell, the width of the cell
expands to over 5 times the width of the text in the Paragraph.

Here is the code for my table, without using a Paragraph:

data = [ ['Name','John'], ['Date', '1/1/07'] ]
ts = [('ALIGN', (0,0), (0,-1), 'RIGHT'),
('ALIGN', (1,0), (1,-1), 'LEFT')]
t = Table( data, style = ts )
t.hAlign = 'LEFT'

Here is the code that uses a Paragraph:

data = [ [Paragraph('Name',styles['Normal']),'John'], ['Date', '1/1/07'] ]
ts = [('ALIGN', (0,0), (0,-1), 'RIGHT'),
('ALIGN', (1,0), (1,-1), 'LEFT')]
t = Table( data, style = ts )
t.hAlign = 'LEFT'

Is it possible to use the Paragraph without it taking up so much space
in the table cell?

Thanks,

Farshid


More information about the reportlab-users mailing list