[reportlab-users] multiple frames on one page

Arkadi Colson arkadi at smartbit.be
Fri Aug 21 07:40:02 EDT 2009

Hi all,

I'm having a problem with frames and pagetemplates. As you can see in
the code below I would like to have 2 frames on the first page but only
one frame(the first one:Fcover) is showing. Because the complete file is
quite big I only included parts of the code. I hope this is ok for
trying to locate the problem.

Thanks in advance.
Arkadi Colson

doc = ssDocTemplate(outputfile)

frame1 =
frame2 =

doc.addPageTemplates( PageTemplate(
id = 'cover',
frames = [frame1,frame2],
pagesize = (210*mm, 297*mm),
onPage = self.FirstPage
) )

story.append( NextPageTemplate('cover') )

class ssDocTemplate(SimpleDocTemplate):

def multiBuild(self, story, canvasMaker=Canvas,
onFirstPage="_doNothing", onLaterPages="_doNothing"):
if onFirstPage is "_doNothing" and hasattr(self,'onFirstPage'):
print "222"
self.pageTemplates[0].beforeDrawPage = self.onFirstPage
if onLaterPages is "_doNothing" and hasattr(self,'onLaterPages'):
print "222"
self.pageTemplates[1].beforeDrawPage = self.onLaterPages

SimpleDocTemplate.multiBuild(self, story, canvasMaker)

def afterPage(self):
self.numPages = max(self.canv.getPageNumber(), self.numPages)
PageNumber = pageNumber()
PageNumber.drawPageNr( self.canv, self.canv.getPageNumber(),
self.title )

def progresshandler(self, what, arg):
if what=='STARTED':
self._lastnumPages = self.numPages

def afterInit(self):
self.numPages = 1
self._lastnumPages = 0

def _allSatisfied(self):
if self._lastnumPages < self.numPages:
return 0
return BaseDocTemplate._allSatisfied(self)

def getTotalPages(self):
return self._lastnumPages

def setTitle(self, title):
self.title = title

More information about the reportlab-users mailing list