[reportlab-users] understanding PageTemplate and BaseDocTemplate
Robin Becker
reportlab-users@reportlab.com
Fri, 25 Jul 2003 14:27:18 +0100
In article <1059128377.25954.9.camel@muaddib.koe.ulm.scan-plus.de>, Igor
Stroh <jenner@dpost.de> writes
Not quite sure what you mean. The intention is that page templates
control frames. The story is made up of flowables and the vanilla doc
template stuff attempts to fill up each available frame in turn.
At frame end we switch to the next frame or if itr's the last on the
page we do the page end page begin handling and if required change page
template.
Normally you should have the first page template first (so nothing is
needed to use it). You then need to use some way to set the
_nextPageTemplateIndex attribute. The SimpleDocTemplate handles this in
its handle_pageBegin method by using the handle. You can also use the
ActionFlowable, NextPageTemplate to set this or directly using
handle_nextPageTemplate. At the end of the current page a swicth to the
page template is made if _nextPageTemplateIndex is set.
The overall sequence is described in doctemplate.__doc__ a bit better
than the above.
>Hi there,
>
>I have a small problem: I need to draw a flyleaf (title) page as the
>first page of a document. I can't use the PageTemplate that is rendered
>for the rest of the pages 'cos it has another layout. I added the
>templates using
>self.addPageTemplates(LaterPages) # default one
>self.addPageTemplates(FirstPage) # title page
>
>before I call self.build(), I do this:
>self.pageTemplates[1].beforeDrawPage = self.createFlyLeaf
>where FlyLeaf() is a method that just prints some debug message.
>Now if I run the program, the createFlyLeaf() method isn't called. It
>seems like all the flowables I have in my document are using the first
>PageTemplate (the LaterPages one). I couldn't find any place in the
>reportlab libs where I can explicitly define a PageTemplate for a
>Flowable (e.g. a FastPara). Could someone point me into the right
>direction?
>I mean, I could use SimpleDocTemplate instead of BaseDocTemplate, but
>I'd like to use a custom canvas for the build() method of
>BaseDocTemplate...
>
>TIA,
>Igor
--
Robin Becker