reportlab question

Scott Hathaway scott_hathaway at riskvision.com
Wed Nov 14 14:33:30 EST 2001


Hello All,

I have a simple script that I am using to create form letters from a text
file with reportlab.
It works ok until the text is longer than xx characters long.  Then the text
is just cut off, not
word wrapped as I would like.  How to I cause reportlab to word wrap the
text?

Here is the code:

import reportlab.pdfgen.canvas
from reportlab.lib import colors
from reportlab.lib.units import inch
import sys

c = reportlab.pdfgen.canvas.Canvas(sys.argv[2])
c.setFillColorRGB(0,0,0)

allText = open(sys.argv[1],'r').read()
pageList = allText.split('#PageBreak#')

for page in pageList:
    c.drawInlineImage('c:/rv_logo.jpg',(.5*inch),(11*inch),100,20)
    t = c.beginText()
    t.setTextOrigin(.5*inch, 10.5*inch)
    t.textLines(page)
    c.drawText(t)
    t = None
    c.showPage()

c.save()


Thanks in Advance!
Scott





More information about the Python-list mailing list