Producing PDFs in landscape orientation with ReportLab
Make sure you've imported
from reportlab.lib.pagesizes import letter, landscape
And then:
canvas.setPageSize(landscape(letter))
Or more generally,
canvas.setPageSize(width, height)
and you can set it to be any size you like. Remember reportlab uses points, where 1 point is 1/72 of an inch. You can also import:
from reportlab.lib.units import inch
Which lets you do things like:
canvas.setPageSize(11*inch, 8.5*inch)
EDIT: Added all the built in page sizes inspired by yentsun.
Diving into the reportlab.lib.pagesizes
source code, we find in all:
A0,A1,A2,A3,A4,A5,A6
B0,B1,B2,B3,B4,B5,B6
LETTER, LEGAL, ELEVENSEVENTEEN
The comments claims that the lowercase letter
has been deprecated since 2001, but is still available. Additionally, two functions are avaialable, portrait
and landscape
that each take in a tuple pagesize, and portrait returns the tuple with the smaller dimension first, and landscape returns the tuple with the larger dimension first.