[reportlab-users] RE: understanding PageTemplate and BaseDocTemplate

Marc Stober reportlab-users@reportlab.com
Fri, 25 Jul 2003 08:59:24 -0400


Hi Igor,

First of all I'm confused why you are adding the later pages template first
and the first page template later?

To get the effect of specifying a page template for a paragraph, you can use
a special flowable called NextPageTemplate. You can use it like any other
flowable, providing the id attribute of whatever page template you want to
come next, as such:
	from reportlab.platypus import NextPageTemplate
	doc.pageTemplates[1].id = "LaterPage"
	story.append(NextPageTemplate("LaterPage"))
Note that it will not take effect until you get to the next page -- either
by inserting a PageBreak, or by running out of room the first page.
Therefore, you still need to set your first page template to be the default
for the document (by making it pageTemplates[0], I think); then I would put
a NextPageTemplate as the last flowable on the first page.

Hope this helps. I'm just a fellow user so if the ReportLab staff responds
with a different answer, please follow their advice over mine!

Take care,
Marc

--
Marc Stober
mstober@dalbar.com - 617-624-7155 
DALBAR, Inc.
The measurement of success.
 
> From: Igor Stroh <jenner@dpost.de>
> To: Reportlab Users <reportlab-users@reportlab.com>
> Date: 25 Jul 2003 12:19:37 +0200
> Subject: [reportlab-users] understanding PageTemplate and 
> BaseDocTemplate
> Reply-To: reportlab-users@reportlab.com
> 
> 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