【发布时间】:2018-08-15 02:26:53
【问题描述】:
我想使用 django-easy-pdf 渲染一个带有 Django 的 pdf 文件。我关注了these instructions,但我得到了一个空的pdf。
这是我的html:
{% extends "easy_pdf/base.html" %}
{% block extra_style %}
{% endblock %}
<% block content %>
<div id="summary-block">
<p>Here goes that square with data.</p>
</div>
<div id="declarations-block">
<p>Here goes the Main content.</p>
</div>
<div id="data-block">
<p>Here goes all the data from the contract.</p>
</div>
<div id="clause-block">
<p>Here goes the Clause content.</p>
</div>
<div id="signatures-block">
<p>Here goes the signatures content.</p>
</div>
<% endblock %>
这是我的views.py:
from django.shortcuts import render
from django.conf import settings
from easy_pdf.views import PDFTemplateView
# Create your views here.
class ContractPDFView(PDFTemplateView):
template_name = 'contract.html'
base_url = 'file://' + settings.TEMPLATES_DIR
download_filename = 'contract.pdf'
def get_context_data(self, **kwargs):
return super(ContractPDFView, self).get_context_data(pagesize='letter', title='Contract', **kwargs)
我不知道我错过了什么。
【问题讨论】:
标签: python django pdf pdf-generation