[reportlab-users] split string by width.

Juan Efren Castillo juanefren at gmail.com
Fri Nov 5 15:23:35 EDT 2010


I need to print a single long string.

reportlab.lib.utils.SimpleSplit works splitting by blank spaces, but
this string has no spaces

My solution was to divide string into "chunks"

y = 0
for t in chunks(r, MAXCHARS):
p.drawString(d.x, page_size[1] - d.y + y, t)
y -= p._leading


How ever I don't like this solution because MAXCHARS is always
different depending on Font and Size of the text.

Any ideas how to calculate MAXCHARS ? or another solution to this?

Thanks in advance.

--
Juan Efrén Castillo Encinas


More information about the reportlab-users mailing list