0
我正在使用reportlab生成pdf。在這裏,我從數據庫檢索配置文件。在打印到數據庫中時,每個配置文件應顯示在下一頁中。爲此,我無法在增加頁面座標時打印該值。Django:增加reportlab中的抽象值
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
感謝答覆,但我得到一個用戶只有相同的輸出。我沒有得到不同的完整名單。 – somechow
你確定你有多個Child_detail記錄嗎? – Reinbach
是的..我有我的數據庫中的100個子記錄 – somechow