[reportlab-users] Printing Variable Length String
Rich Shepard
rshepard at appl-ecosys.com
Wed Nov 7 17:21:41 EST 2007
On Wed, 7 Nov 2007, Tim Roberts wrote:
> No, bulky is pretty much the rule. Here's what I use.
Thanks, Tim.
What I wrote is:
X,Y = tb.getXY()
maxLineLen = 175
origLineLen = pg.stringWidth(strings_tuple[1], pg._fontname, pg._fontsize)
if origLineLen > maxLineLen:
chunks = strings_tuple[1].split()
nWords = len(chunks)
i = 1
hunk = ''
for i in range(nWords):
hunk += chunks[i] + ' '
i += 1
newLineLen = pg.stringWidth(hunk, pg._fontname, pg._fontsize)
if newLineLen > maxLineLen:
tb.textLine(hunk[:-1])
tmp = chunks[i:]
hunk = ''
i = 1
tb.setXY(270,Y-13)
else:
continue
It's specific to the one situation, but in its own crude way it works.
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