2

次のコードを使用して出力 pdf に表示されるアラビア語が間違っている:

template = get_template(template_src)
context = Context(context_dict)
html = template.render(context)
result = StringIO.StringIO()    
pdf = pisa.pisaDocument(StringIO.StringIO(
        html.encode(pdf_encoding)), result, encoding=pdf_encoding) # pdf_encoding = 'utf-8'

テンプレートで、文字セットとフォントを設定します。

<meta http-equiv="content-type" content="text/html; charset=utf-8">
@font-face {
              font-family: AmiriRegular;
              src: url(/usr/share/fonts/opentype/fonts-hosny-amiri/amiri-regular.ttf);
            }
            body { font-family: AmiriRegular; }

出力: ここに画像の説明を入力

スナップショットのアラビア語のテキストは次のようになります。

ياسر حسن
4

1 に答える 1