[reportlab-users] Reportlab and Django - Beginner - landscape A4
leau2001
laurent.caron.3 at free.fr
Fri Sep 4 03:33:17 EDT 2009
HEllo,
Im a new user of Reportlab library, and i try to use it with my Django local application. I tried to use table on my page.. i succeed but in want now to use A4 landscape for my pdf... i tried pagesize=landscape(A4), but don't work...
I anyone have some advice for reportlab with django, i get it...
Thx for Help
laurent
Here my test_pdf view :
# Create the HttpResponse object with the appropriate PDF headers.
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=somefilename.pdf pagesize=landscape(A4)'
landscape
buffer = StringIO()
# Create the PDF object, using the StringIO object as its "file."
p = canvas.Canvas(buffer)
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
p.drawString(100, 100, "Hello world.")
t=Table(data_list)
t.setStyle(TableStyle([('BACKGROUND',(1,1),(-2,-2),colors.green),('TEXTCOLOR',(0,0),(1,-1),colors.red)]))
w, h = t.wrapOn(p,400,100)
t.drawOn(p,0,300)
# Close the PDF object cleanly.
p.showPage()
p.save()
# Get the value of the StringIO buffer and write it to the response.
pdf = buffer.getvalue()
buffer.close()
response.write(pdf)
return response
More information about the reportlab-users
mailing list