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

后端 未结 6 803
情歌与酒
情歌与酒 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:44

    I faced the same problem with cyrillic characters.

    The solution contained two steps: 1. Point out the font file in your HTML file

    
    

    2. Give "pisa" root path (so that it find font file by relative path) in my case it was something like this

    pdf = pisa.pisaDocument(html, result, path=PATH_TO_DJANGO_PROJECT)
    

    because fonts were placed at PATH_TO_DJANGO_PROJECT/files/arial.ttf

提交回复
热议问题