[reportlab-users] Using landscape in DocTemplates

Mike Driscoll mike at pythonlibrary.org
Wed Jan 8 16:07:53 EST 2014


Hi,

I thought I had this figured out, but I guess not. I am creating a
SimpleDocTemplate like this:

self.doc = SimpleDocTemplate(fileObj, pagesize=letter,
leftMargin=l_margin)

And then building it like this:

self.doc.build(self.story,
onFirstPage=self.create_pdf

In the create_pdf method, I tell reportlab that I want the canvas to be in
landscape:

self.c = canvas
self.c.setPageSize( landscape(letter) )

Unfortunately, if I create a table or other flowable that is too large to
fit on the first page, the second page ends up being in portrait mode. I
tried adding the second kwarg for the build operation (onLaterPages) and
told it to also set the size to landscape, but it doesn't appear to work
correctly...the second page goes landscape, but the table is mostly missing
with only the last row or so showing up on the page. So somehow it seems
that reportlab is drawing the table on the second page as if it were in
portrait mode and then when it saves it, it flips it to landscape?

Is there some way to tell the template to just be in landscape mode across
all pages?

Thanks!

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140108/41c73491/attachment.htm>


More information about the reportlab-users mailing list