XML parsing and ReportLab combination cause extra single quote in PDF
vmhe at alumni.princeton.edu
vmhe at alumni.princeton.edu
Tue May 15 21:56:34 EDT 2001
The below thread is from reportlab-users, but the problem seems to
stem from my xml parsing.
Essentially, any XML that I parse and then add to a PDF using
reportlab is added with an extra apostrophe or single quote before
it. Trimming the string using str = str[1:len(str)] removes the
first character from the string, not the single quote.
Has anyone seen this or know how to fix it? It is causing much
anguish.
Many thanks,
Ginger
vmhe @ alumni.princeton.edu
-----------------------------------------
It looks like the problem is being caused by XML parsing - I'm going
to also post this to xml-sig.
To illustrate the problem I added the following to
test/test_paragraph.py:
from xml.dom.minidom import parseString
##PARSE XML
doc = parseString('<myxml greeting="this is XML"></myxml>')
tags = doc.getElementsByTagName("myxml")
for t in tags :
print t.getAttribute("greeting")
story.append(
Paragraph(t.getAttribute("greeting"),
styNormal))
doc.unlink()
The resulting pdf has:
'this is XML
at the bottom, but the output of the program (from print
t.getAttribute("greeting") ) is:
this is XML
This behavior is not confined to Paragraphs, it seems to be all
Flowables.
Thanks again for any help.
--- In reportlab-users at y..., Robin Becker <robin at r...> wrote:
> ...
> certainly this shouldn't happen. I just checked some simple examples
> and it isn't happening for me (with the latest source).
>
> Could it be a problem with style eg a bullet?
>
> If all else fails can you try changing the test example in
> test/test_paragraphs.py to illustrate your problem? I have just
checked
> in some minor changes to this at line 110
>
> story.append(Paragraph("""This has <font color=blue>blue
> text</font> here.""", styNormal))
> story.append(Paragraph("""This has <i>italic text</i>
here.""",
> styNormal))
> story.append(Paragraph("""This has <b>bold text</b>
here.""",
> styNormal))
> story.append(Paragraph("""This has m<super>2</super> a
> superscript.""", styNormal))
> story.append(Paragraph("""This has m<sub>2</sub> a
> subscript.""", styNormal))
>
> and this looks abosultely right for me.
> --
> Robin Becker
> In article <9dq4ff+fd9l at e...>, vmhe at a... writes
> >hello --
> >
> >We are using ReportLab and have had much success, with one major
> >exception - before the text in all Paragraphs and before any font
> >style changes ( < /b > , < /i >, etc.) within a Paragraph, a stray
> >single quote/apostrophe ( ' ) appears in the PDF.
> >
> >The apostrophe is definitely being inserted by the Paragraph,
because
> >debugger output right before the Paragraph is formed shows no
> >apostrophe.
> >
> >Has anyone seen this? Have any suggestions? I have been wading
> >through paragraph.py and can't figure out our problem.
> >
> >thank you,
> >Ginger
> >
> >vmhe @ alumni.princeton.edu
> >
More information about the Python-list
mailing list