Reputation: 6304
I am trying to display Chinese characters using reportlab pisa. The generated Chinese words become black blocks. I am using UTF-8 to generate the PDFs
def render_to_pdf(template_src, context_dict):
"""Function to render html template into a pdf file"""
template = get_template(template_src)
context = Context(context_dict)
html = template.render(context)
result = StringIO.StringIO()
pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), result)
if not pdf.err:
return HttpResponse(result.getvalue(), mimetype='application/pdf')
return HttpResponse('We had some errors<pre>%s</pre>' % escape(html))
Upvotes: 1
Views: 816
Reputation: 174624
This is a font problem, as whatever font you need to display is not embeddable by reportlabs in the pdf.
Suggest you check the reportlabs ftp server for the font packages you need.
Upvotes: 3