[reportlab-users] Error using encoding="utf-8" to output RML to PDF

Robin Becker robin at reportlab.com
Thu Jun 8 07:20:04 EDT 2017


Hi Robert,

can you email me (attached as a zip) the smallest possible example where this 
happens? Also what version of python/platform are you using?

I have tested by just inserting the ÷ into a simple test rml


<!DOCTYPE document SYSTEM "../rml.dtd">
<document filename="tdivide.pdf" invariant="1">

<stylesheet>
<paraStyle
         name="intro"
         fontName="Helvetica"
         fontSize="12"
         leading="12"
         />
</stylesheet>

<pageDrawing>
<drawCentredString x="4.1in" y="5.8in">
Hello World. First Page Drawing ÷
</drawCentredString>
</pageDrawing>

</document>


that works for me with python 2.7 3.3...

I suspect you have been more formal and have put in some encodings at the top 
somehow. The encoding eclared appears to be utf8 and the text of the rml appears 
to be something other than utf8.

On 08/06/2017 11:37, Robert Sullivan wrote:
> Hello,
> 
> I'd like to use some entities such as ÷, × and ≈ in my
> RML template that outputs to a PDF but I get an error:
> 
> rml2pdf.go(rml, outputFileName=buffer)
>    File "rlextra-3.3.29/src/rlextra/rml2pdf/rml2pdf.py", line 6018, in go
> pyRXPU.error: Declared encoding UTF-8 is incompatible with UTF-16 which was
> used to read it
> 
> I've read in this previous message
> https://pairlist2.pair.net/pipermail/reportlab-users/2017-March/011607.html
> that PDF may not allow UTF-8 so I'm a bit stuck as to what to do.
> 
> Many thanks,
> 
> Robert
......

-- 
Robin Becker


More information about the reportlab-users mailing list