Python 2.7 を使用して Google App Engine で PDF ファイルを作成しています。テンプレート html ファイルを使用して PDF コンテンツを生成しています。すべてのステップで UTF-8 コーディングを使用しているとマークしたと思いますが、作成された PDF は正しく表示されません。これまでのところ、ローカルホストのみでテストしました。私が間違っていることを教えてもらえますか?
テンプレート ドキュメント。ファイル プロパティに UTF-8 コーディングを設定し、メタデータに utf-8 文字セットを配置しました。
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> Działając </body> <html>
PDF ファイルを作成するコードは、すべての可能な場所で UTF-8 コーディングをマークしています。コースコードファイルもUTF-8です。
# -*- coding: utf-8 -*- ... code skipped # f = codecs.open(os.path.join(APP_TEMPLATES, 'test.html'), encoding ='utf-8') # fdata = f.read() # f.close() # htmpPage = render_template_string(fdata, encoding='utf-8') htmpPage = render_template('test.html', encoding='utf-8') pdfOUTPUT = StringIO.StringIO() pisa.pisaDocument(htmpPage,dest=pdfOUTPUT, encoding='utf-8') # pisa.CreatePDF(htmpPage, dest=pdfOUTPUT, encoding='UTF-8') response = make_response(pdfOUTPUT.getvalue()) response.headers.set('Content-Disposition', 'attachment', filename='test' + '.pdf') response.headers.set('Content-Type', 'application/pdf;charset=UTF-8')