장고에서 WeasyPrint를 사용하여 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를 생성하기 위해 사용자 정의 글꼴을 포함하는 방법을 말할 수 있다면 매우 유용 할 것입니다. OS (Ubuntu 14.04)에 글꼴을 설치했지만 작동하지 않습니다.
나는 이것들에 관하여 웹에서 많은 것을 수색했다. 그러나 적절한 해결책을 찾지 못했습니다. 렌더링 할 때 당신이 당신의 스타일 시트를 포함해야합니다
@page {
@top-right{
content: "Page " counter(page) " of " counter(pages);
}
}
: Weasyprint 이후