2
我正在使用WeasyPrint在Django中生成PDF。我可以生成静态html文件,PDF像下面 -用WeasyPrint生成具有共同页眉/页脚和分页的PDF
from django.template import Context, Template
import weasyprint
with open('static_file.html', 'r') as myfile:
html_str = myfile.read()
template = Template(html_message)
context = Context({'some_key': 'some_value'})
rendered_str = template.render(context)
weasyprint.HTML(string=rendered_str).write_pdf('generated.pdf')
但我想生成一个PDF中,我可以包括在每一个页面一个共同的页眉/页脚和添加分页。
此外,如果任何人都可以告诉如何包含自定义字体以生成PDF,它将非常有帮助。我已经在操作系统(Ubuntu 14.04)中安装了字体,但它不起作用。
我在网上搜索了很多关于这些的东西。但找不到合适的解决方案。