Reportlab : How to switch between portrait and landscape?

I finally figured out the best way to do it by myself :

I added a new PageTemplate in my DocTemplate with landscape settings, and then simply used NextPageTemplate from the reportlab.platypus package :

array.append(NextPageTemplate('landscape'))

To get back in portrait, i use :

array.append(NextPageTemplate('portrait'))

This allows a pretty nice flexibility.


Use the landscape and portrait functions that are already in the pagesizes module.

from reportlab.lib.pagesizes import letter, landscape
c = canvas.Canvas(file, pagesize=landscape(letter))