1

I'm looking for some inspiration. I have some code that is changing the orientation of a page from the default portrait to landscape however the frames I create within the pagetemplates always get created as if they are on a portrait page still.

doc = BaseDocTemplate('test2.pdf', pagesize=landscape(A4))
myFrameThresholdLeft = Frame(
                    doc.leftMargin,
                    doc.bottomMargin,
                    doc.width / 2,
                    doc.height,
                    showBoundary=1  # set to 1 for debugging
                )

emptyTemplate = PageTemplate(id='emptyTemplate',
                         pagesize=landscape(A4),
                         frames=[myFrameThresholdLeft,
                                 myFrameThresholdRight],
                         onPage=emptyLayout)

elements.append(NextPageTemplate('emptyTemplate'))
elements.append(PageBreak())

I think this is because the values returned by the e.g. doc.width methods are not changing as I change the pagesize in the pagetemplate. Can someone put me on the right tracks here?

Noxy
  • 11
  • 2
  • Possible duplicate of [Reportlab : How to switch between portrait and landscape?](https://stackoverflow.com/questions/5913682/reportlab-how-to-switch-between-portrait-and-landscape) – fatih_dur Dec 19 '17 at 22:25

0 Answers0