[reportlab-users] Printing Variable Length String

Tim Roberts timr at probo.com
Mon Nov 5 14:40:41 EST 2007


Rich Shepard wrote:

>

> I extract a tuple of strings from the database table row (there's

> only 1

> row in this table), and make a list of lables (one for each string). The

> platypus table data is:

>

> tabData = [[labName[0],strings_tuple[0]],

> [labName[1],strings_tuple[1]],

> [labName[2],strings_tuple[2]],

> [labName[3],strings_tuple[3]],

> [labName[4],strings_tuple[4]],

> [labName[5],strings_tuple[5]],

> [labName[6],strings_tuple[6]],

> [labName[7],strings_tuple[7]]]


You might consider writing this as:
tabData = zip( labName, strings_tuple )



> If col_width and col_height are not explicit in the Table creation,

> can I

> assume that a long string will wrap without running off the right

> margin of

> the page? Or, should I expliticaly set the width and let the height

> float to

> accommodate a long string?


A table cell never wraps. Again, I think you are assuming of ReportLab
as a programmable word processor. It's not. It is a very direct path
from strings to paper.

Have you taken a look at the ReportLab tests? In "test_table_layout.py"
in particular, you sen see what happens in the first two examples. The
first example specifies a fixed column width, and the long string simply
runs on into the rest of the table. The second example specifies no
size info, and the table is resized to accomodate the long string, even
though it exceeds the page margin. Note, however, the fourth example,
where a Paragraph has been embedded into a table cell. That's the way
to get automatic word wrapping.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list