[reportlab-users] encoding errors
Dirk Holtwick
holtwick at spirito.de
Tue Jan 23 06:58:02 EST 2007
Robin Becker schrieb:
> just carping won't make any friends, but bug reports are welcome :)
>
Do you have a bugtracking system where to put those?
> Anyhow what were the actual string/unicode values that were used for the three?
> I know we've done Japanese for this so it should be possible to get it working.
>
Then please try this one, where "Broschüre" contains the German Umlaut:
# -*- coding: ISO-8859-1 -*-
from reportlab.platypus import *
from reportlab.lib.styles import *
from reportlab.rl_config import *
from reportlab.lib.units import *
from reportlab.platypus.para import *
import os
import types
class PmlBaseDoc(SimpleDocTemplate):
def beforePage(self):
test = unicode("Broschüre","latin1")
# test = "ASCII Sample"
self.canv.setAuthor(test)
self.canv.setSubject(test)
self.canv.setTitle(test)
styles = getSampleStyleSheet()
def test():
doc = PmlBaseDoc("test.pdf")
story = []
story.append(Paragraph("Hello World", styles["Normal"]))
doc.build(story)
if __name__=="__main__":
test()
os.system("start test.pdf")
And that's the error message:
Traceback (most recent call last):
File "title.py", line 29, in ?
test()
File "title.py", line 26, in test
doc.build(story)
File "c:\work\reportlab\reportlab\platypus\doctemplate.py", line 898,
in build
BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
File "c:\work\reportlab\reportlab\platypus\doctemplate.py", line 749,
in build
self._endBuild()
File "c:\work\reportlab\reportlab\platypus\doctemplate.py", line 698,
in _endBuild
if getattr(self,'_doSave',1): self.canv.save()
File "c:\work\reportlab\reportlab\pdfgen\canvas.py", line 870, in save
self._doc.SaveToFile(self._filename, self)
File "c:\work\reportlab\reportlab\pdfbase\pdfdoc.py", line 215, in
SaveToFile
f.write(self.GetPDFData(canvas))
File "c:\work\reportlab\reportlab\pdfbase\pdfdoc.py", line 230, in
GetPDFData
self.info.digest(self.signature)
File "c:\work\reportlab\reportlab\pdfbase\pdfdoc.py", line 1337, in digest
md5object.update(str(x))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
position 6: ordinal not in range(128)
More information about the reportlab-users
mailing list