I create reports by means of RML(XML) and parse to PDF (use pyjon.reports).

In output pdf polish char not display

my xml file

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="encoding-test-utf8.pdf">

    <pageTemplate id="main">
      <frame id="first" x1="72" y1="72" width="451" height="698"/>


    <title>Test of Encoding: UTF-8</title>
    ą ź ś ć ł ę
     <spacer length="1in" />

My Python code,

# -*- coding: utf-8 -*-

from rml2pdf.factory import ReportFactory

factory = ReportFactory()

Now i try debug but result is not effect. ( sorry for my english )

Recommended Answers

All 3 Replies

What version of Python are you using?

If you are using Python3 you may get a bytearray rather than a string and have to decode it first ...

# tested with Python32

# string of Polish characters
mystr = "ą ź ś ć ł ę"

# encode string to <class 'bytes'> or bytearray
mybytes = mystr.encode("utf8")

# decode <class 'bytes'> to string
mystr2 = mybytes.decode("utf8")


'''result ...
ą ź ś ć ł ę
b'\xc4\x85 \xc5\xba \xc5\x9b \xc4\x87 \xc5\x82 \xc4\x99'
ą ź ś ć ł ę

Just a note:
The IDLE or the improved VIDLE IDE seem to handle the foreign characters properly. Some other IDE's screw this up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.