Lino Website

surf notes

Moved to Reportlab 2.0

Saturday, 21. October 2006 7:30.

I upgraded the ReportLab Toolkit on my machine to 2.0. The only code change was to to remove the .encode() calls in PdfTextPrinter.write() since ReportLab now supports Unicode.

But then I hoped that I would now get the boxchars into the PDF by simply not replacing them any more by their replacements from HACK_BOXCHARS:

for k,v in HACK_BOXCHARS.items():
    text = text.replace(k,v)

Result: yes, there is no longer an EncodingError as with 1.x, this is promising. But still the characters are not rendered correctly. I explained the prblem and asked for help from


I'd like to create PDF files with texts encoded in cp437 or cp850. These texts also contain box characters which are not part of the latin character set. But most Windows machines can display and print such text if you use a font that provides the OEM charset (and if you activate the appropriate codepage).

For example the following script should print a horizontal line that is 20 characters wide. First on the consoloe ("print s"), then in a PDF file. The console displays it correctly, but the PDF file doesn't.

import os
from reportlab.pdfgen import canvas
from reportlab.lib.units import mm
print s
canvas = canvas.Canvas(filename)

I guess that I must specify the right font to use — but how?


(More about why I ask this:

Refering articles:

Copyright 2001-2007 Luc Saffre.
Generated 2007-06-07 16:22:51