首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >pisa django将汉字显示为黑色方块

pisa django将汉字显示为黑色方块
EN

Stack Overflow用户
提问于 2011-12-25 12:09:37
回答 1查看 701关注 0票数 1

我正在尝试使用reportlab pisa显示中文字符。生成的中文单词会变成黑块。我正在使用UTF-8生成PDF

代码语言:javascript
运行
AI代码解释
复制
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))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-25 13:29:09

这是一个字体问题,因为您需要显示的任何字体都不能被reportlabs嵌入到pdf中。

建议您查看reportlabs ftp server中是否有您需要的字体包。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8629521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档