[reportlab-users] Error with the character ampersand

paulino1 at sapo.pt paulino1 at sapo.pt
Tue Oct 24 08:35:54 EDT 2006


I have a cgi script that grab data from a database, send a table to the browser
and generate a pdf with the same data, for printing.

In this statement "Paragraph( unicode( acum[v][0] , 'latin-1')" when the
variable acum[v][0] has in it's text the character & (ampersand), the
fallowing error is returned:



A problem occurred in a Python script. Here is the sequence of function calls
leading up to the error, in the order they occurred.

 F:\http\cgi-bin\balcc01.pyw
  137 ak.sort()

  138 for v in ak :

  139     linpdf=[ v, Paragraph( unicode( acum[v][0] , 'latin-1'),
style=ppistyle ),

  140              Formata( acum[v][1] ), Formata( acum[v][2] ), Formata(
acum[v][1]-acum[v][2] ) ]

  141     final.append(linpdf)

linpdf = ['6811175', Paragraph( 'style' <ParagraphStyle 'normal... 'bold' 0 )
#ParaFrag] ) #Paragraph, '4.993,34', '0,00', '4.993,34'], v = '6811176',
Paragraph = <class reportlab.platypus.paragraph.Paragraph>, builtin unicode =
<type 'unicode'>, acum = {'0': ['DESP.INV E DESENV.', 0.0, 584342.40000000002],
'09': ['CONTAS DE ORDEM', 0.0, 584342.40000000002], '093': ['GARANTIAS PREST. AO
MUNICIPIO', 0.0, 584342.40000000002], '0931': ['GARANTIAS RECEBIDAS', 0.0,
549632.40000000002], '0934': ['PRESTADORES DE GARANTIAS', 0.0, 34710.0],
'09343': ['OUTROS CREDORES', 0.0, 34710.0], '2': ['TERCEIROS', 3293005.79,
24470551.330000006], '22': ['FORNECEDORES', 0.0, 189427.84999999992], '228':
['FORNEC.\x96FACT.RECEP E CONFER.', 0.0, 189427.84999999992], '2281':
['FACTURAS REGISTADAS', 0.0, 189427.84999999992], ...}, style undefined,
ppistyle = <ParagraphStyle 'normal'>, Formata = <function Formata>
 C:\Python24\reportlab\platypus\paragraph.py in __init__(self=Paragraph(
'caseSensitive' 1 'encoding' 'utf8' ) #Paragraph, text=u'J.AV.P.&FIL3-10-05
TOTTA CR ES', style=<ParagraphStyle 'normal'>, bulletText=None, frags=None,
caseSensitive=1, encoding='utf8')
  443         self.caseSensitive = caseSensitive

  444         self.encoding = encoding

  445         self._setup(text, style, bulletText, frags, cleanBlockQuotedText)

  446

  447     def __repr__(self):

self = Paragraph( 'caseSensitive' 1 'encoding' 'utf8' ) #Paragraph, self._setup
= <bound method Paragraph._setup of Paragraph( '...tive' 1 'encoding' 'utf8' )
#Paragraph>, text = u'J.AV.P.&FIL3-10-05 TOTTA CR ES', style = <ParagraphStyle
'normal'>, bulletText = None, frags = None, global cleanBlockQuotedText =
<function cleanBlockQuotedText>
 C:\Python24\reportlab\platypus\paragraph.py in _setup(self=Paragraph(
'caseSensitive' 1 'encoding' 'utf8' ) #Paragraph, text='J.AV.P.&FIL3-10-05
TOTTA CR ES', style=<ParagraphStyle 'normal'>, bulletText=None, frags=None,
cleaner=<function cleanBlockQuotedText>)
  467             style, frags, bulletTextFrags = _parser.parse(text,style)

  468             if frags is None:

  469                 raise "xml parser error (%s) in paragraph
beginning\n'%s'"\

  470                     % (_parser.errors[0],text[:min(30,len(text))])

  471             if bulletTextFrags: bulletText = bulletTextFrags

global _parser = <reportlab.platypus.paraparser.ParaParser instance>,
_parser.errors = ['; missing in entityref'], text = 'J.AV.P.&FIL3-10-05 TOTTA
CR ES', builtin min = <built-in function min>, builtin len = <built-in function
len>

xml parser error (; missing in entityref) in paragraph beginning
'J.AV.P.&FIL3-10-05 TOTTA CR ES': None



More information about the reportlab-users mailing list