我正在使用reportlab 生成pdf。在这里,我从数据库中检索配置文件。打印到数据库时,每个配置文件都应显示在下一页中。为此,我无法在增加页面坐标的同时打印该值。
def reportlab(request):
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'
buffer = BytesIO()
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
child = Child_detail.objects.all()
for child1 in child:
name = child1.name
p = canvas.Canvas(buffer)
p.drawString(500, 400, name)
p.showPage()
p.save()
pdf = buffer.getvalue()
buffer.close()
response.write(pdf)
return response