In django project trying to create a pdf using python-reportlab.
from reportlab.pdfgen import canvas
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
p = canvas.Canvas(response)
p.drawString(10, 800, "Name")
p.drawString(10, 900, "Address")
p.drawString(10, 1000, "School")
p.showPage()
p.save()
On output pdf It only shows the Name
, what happened to other two strings?
The coordinates for "Address" and "School" are simply outside of the page. The origin of the reportlab coordinate system is bottom-left, with the x coordinate going to the right and the y coordinate going up. Try the following instead:
p.drawString(10, 800, "Name")
p.drawString(10, 790, "Address")
p.drawString(10, 780, "School")