[reportlab-users] Confirming my suspicions
andy at reportlab.com
Wed Mar 2 04:47:34 EST 2005
> my last foray into PDFs was last year but was able to pick up my code and
> work through it quite quickly: Python be thank! I'd managed to avoid
> PageTemplates, et. al as I was working on single page documents. Can't
> avoid that now so I've spent some time going through the documentation. I
> was hoping I'd be able to get away with using SimpleDocTemplate but I'm
> beginning to think not. Is it possible to vary Frame dimensions
> between the
> first page and subsequent pages? The source seems to indicate
> this might be
> possible but I've tried setting the margins in onFirstPage() and
> onOtherPages() to no affect - which doesn't surprise me if they
> are called
Make two (or more) page templates: one for the first page (call it "first")
and and one for the subsequent pages (call it "rest"). Early in the
story, somewhere that would definitely occur one page one,
put in this:
The next new page that begins will use the name 'rest'.
reportlab/test/test_platypus_leftright.py contain examples of
template changes. The output PDFs will go in your temp directory.
You can also (since a few months back) add a LIST of templates
so it can do alternating left and right pages for you. e.g.
If you need dynamically adjusted margins for some reason,
hacking margins on SimpleDocTemplate is highly unlikely to work
as it's a wrapper which constructs a single 'real' page template object
with one frame. If you use BaseDocTemplate, and hack the frame list,
it might work; but the PageTemplate is reused and not rebuilt each time
so care is needed.
Hope this helps,
More information about the reportlab-users