[reportlab-users] PageTemplate's onPageEnd

Tim Roberts timr at probo.com
Fri Aug 5 12:37:11 EDT 2005


On Fri, 5 Aug 2005 12:05:50 +0200 (CEST), Nicholas Wieland 
<nicholas_wieland at yahoo.it> wrote:

>Ok, some more infos that suggest that probably I didn't undestand onPageEnd ...
>I've added the footer to my first PageTemplate (the cover), and the generated pdf contained the big rect on the first and second page, exactly at the same place.
>I'm lost, I don't know why RL calls onPageEnd for both pages, even if I use it only on the first, and why it doesn't call it when I explicitely ask for it, on the second page. 
>


Ah, I see the problem, I think.  You are assuming that BaseDocTemplate 
will automatically advance to the second PageTemplate when the cover 
page is complete.  Not so.  BaseDocTemplate never changes the 
PageTemplate on its own.  Thus, it's never getting to your second 
template.  YOU need to do the switch when you detect the particular 
conditions for a change.  Take a look at SimpleDocTemplate in 
doctemplate.py.  Notice how it uses handle_pageBegin to switch to the 
second page template.

In fact, you may find that SimpleDocTemplate is a better base for you 
than BaseDocTemplate, unless you expect to need some unusual effects.  
Alternatively, you can append a NextPageTemplage() call in your 
report_story at the point where you want to change templates.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list