[reportlab-users] Error with Unicode?
Schollnick, Benjamin
Benjamin.Schollnick at xerox.com
Fri Jun 17 11:16:43 EDT 2005
Folks,
I'm working on an reporting module that I am outputting to
PDF...
But I'm still new with Unicode, and I'm running into a unicode
issue
with ReportLab...
(Or I'm missing handling the unicode management....)
Now I'm processing the data from a XML file...
Accessing a Database to processing the audit results...
And exporting a PDF file for each XML file that I'm
processing...
(The XML is the raw Audit data, the database contains the raw
license data, and the PDF file contains the check list for the
audit)
I believe the following code...
print "processing: ", audit_file_name
for x in classifications:
## internal_document.RL_Document.append ( "<B> %s </B>" % x)
data = return_classification_in_listing ( x[0], listing)
for name in data:
normal = ParagraphStyle ('Normal')
internal_document.RL_Document.append ( Paragraph
(escape(name), normal ) )
# internal_document.RL_Document.append ( name )
#
internal_document.output_document ( filename,orientation )
is where it is breaking... Specifically, if
name = "American Greetings(r) Art"
The "Registered" (r) symbol is causing it to "gack"...
I added the escape(name) (escape = from xml.sax.saxutils import
escape)
in case the (R) symbol is a XML literal. It will gack with or
without the
escape()...
Any suggestions? The code is working fine for the majority of
the cases...
- Benjamin
traceback ---
processing: .\Audit_USN03811_U233JYHZA658-20050906-082834.xml
Traceback (most recent call last):
File "C:\develope\security\software_listings.py", line 229, in ?
main ()
File "C:\develope\security\software_listings.py", line 224, in main
write_page ( stored_profile, stored_machinename, stored_time,
audit_file_nam
e, listing, software_Classifications)
File "C:\develope\security\software_listings.py", line 118, in
write_page
orientation )
File "rl_wrapper.py", line 124, in output_document
onLaterPages = self.All_Other_Pages )
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\doctemplate.p
y
", line 814, in build
BaseDocTemplate.build(self,flowables)
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\doctemplate.p
y
", line 644, in build
self.handle_flowable(flowables)
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\doctemplate.p
y
", line 562, in handle_flowable
if self.frame.add(f, self.canv, trySplit=self.allowSplitting):
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\frames.py",
li
ne 139, in _add
flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w)
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\flowables.py"
,
line 97, in drawOn
self._drawOn(canvas)
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\flowables.py"
,
line 82, in _drawOn
self.draw()#this is the bit you overload
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\paragraph.py"
,
line 474, in draw
self.drawPara(self.debug)
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\paragraph.py"
,
line 722, in drawPara
t_off = dpl( tx, offset, lines[0][0], lines[0][1], noJustifyLast and
nLines=
=1)
File
"C:\develope\Python24\Lib\site-packages\reportlab\platypus\paragraph.py"
,
line 59, in _leftDrawParaLine
tx._textOut(join(words),1)
File
"C:\develope\Python24\Lib\site-packages\reportlab\pdfgen\textobject.py",
line 311, in _textOut
self._code.append('%s%s' % (self._formatText(text), (TStar and ' T*'
or ''))
)
File
"C:\develope\Python24\Lib\site-packages\reportlab\pdfgen\textobject.py",
line 306, in _formatText
text = self._canvas._escape(text)
File
"C:\develope\Python24\Lib\site-packages\reportlab\pdfgen\canvas.py",
line
231, in _escape
return _escapePDF(s)
File
"C:\develope\Python24\Lib\site-packages\reportlab\pdfbase\pdfutils.py",
l
ine 139, in _escape
return join(map(lambda c, d=_ESCAPEDICT: d[c],s),'')
File
"C:\develope\Python24\Lib\site-packages\reportlab\pdfbase\pdfutils.py",
l
ine 139, in <lambda>
return join(map(lambda c, d=_ESCAPEDICT: d[c],s),'')
KeyError: u'\xae'
C:\develope\security>
More information about the reportlab-users
mailing list