Is there a way to generate pdf containing non-ascii symbols with pisa from django template?

后端 未结 6 800
情歌与酒
情歌与酒 2021-02-05 08:11

I\'m trying to generate a pdf from template using this snippet:

def write_pdf(template_src, context_dict):
    template = get_template(template_src)
    context          


        
6条回答
  •  灰色年华
    2021-02-05 08:42

    Try replacing

    pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), result)
    

    with

    pdf = pisa.pisaDocument(StringIO.StringIO(html), result, encoding='UTF-8')
    

    Or checkout this answer to html to pdf for a Django site?

提交回复
热议问题