[reportlab-users] Printing Variable Length String

Rich Shepard rshepard at appl-ecosys.com
Mon Nov 5 13:04:40 EST 2007


On Sun, 4 Nov 2007, timr at probo.com wrote:


> It's possible to use a platypus Paragraph in an isolated context to do

> this word-wrapping, but it really isn't that hard to do word-wrapping on

> your own. You can split() the string on white space, and keep adding

> words one at a time until the stringWidth() exceeds the length you want,

> and then back off one word.


Thanks, Tim. What I did over the weekend was to use platypus for this one
report.

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]]]

t = Table(tabData)
t.setStyle(tstyle)

where strings_tuple[1] has variable length.

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?

Rich

--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863


More information about the reportlab-users mailing list