我使用pisa从html到pdf进行打印。我有一个问题。 如果数据量很少,则比在第一页打印。如果数据量多于他在下一页打印的数据,但第一页是空的。 你怎么看待这件事? 请帮帮我
table {
-pdf-keep-with-next: true;
}
@page {
size: letter portrait;
margin-right: 30pt;
margin-left: 30pt;
}
@frame content_frame {
left: 50pt;
width: 512pt;
top: 50pt;
height: 692pt;
}
context = Context(context_dict)
html = template.render(context)
result = StringIO.StringIO()
pisa.CreatePDF(html.encode("UTF-8"), result, encoding='UTF-8', link_callback=self.fetch_resources)
response = HttpResponse(result.getvalue(), mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=report-%s-%s.pdf' % (start_date, end_date)
RequestContext(request)
<tbody>
<tr class="text-center">
<td>{% trans "Date" %}</td>
<td class="padding-top-5">
<p class="text-center"> {% trans "Journal" %} </p>
<p style="margin: 0 5pt;">{% trans "history, status, diagnosis and treatment for the treatment of recurrent disease" %}</p>
</td>
<td>{% trans "Doctor" %}</td>
</tr>
{% for reception in receptions %}
<tr>
<td class="text-center" style="width: 30%; vertical-align: top">
<p class="separator"> </p>
{{ reception.date_created|date:"d F Y" }}
</td>
<td>
<div style="padding: 5px">
{% if reception.result|length_is:0 or reception.result == None %}
{% else %}
{{ reception.result|linebreaks }}
{% endif %}
</div>
<td style="vertical-align: top; width: 30%">
<p class="separator"> </p>
{{ reception.doctor.doctor_name }}
</td>
</tr>
{% endfor %}
</tbody>
</table>