[reportlab-users] black squares for every newline

Andy Robinson andy at reportlab.com
Tue Nov 21 19:09:34 EST 2006


dimitri pater wrote:

> Hi,

>

> when I do this (snippet):

>

> bodytext=open('sampletext.txt','r').readlines()

>

> for line in bodytext:

> textobject.textLine(line)

> c.drawText(textobject)

>

> I use ("Helvetica",12) as the argument for setFont

>

> There are black squares for every newline in the PDF. The sampletext.txt

> file is saved as a UTF-8 file.

>

> I am still new to reportlab (two days now), so I could use some help ;-)

> I did not find answers to my question on the web.


Your method of parsing the file has resulted in every line having a
newline character at the end. This is not a valid glyph in the font
so you get a nasty blob. Try stripping the whitespace from the line
before printing it e.g.

> for line in bodytext:
> textobject.textLine(line.strip())
> c.drawText(textobject)


HTH

- Andy


More information about the reportlab-users mailing list