[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 =
Frame(85*mm,30*mm,125*mm,55*mm,leftPadding=0*mm,rightPadding=0*mm,topPadding=0*mm,bottomPadding=0*mm,id='Fcover',showBoundary=0)
frame2 =
Frame(10*mm,20*mm,100*mm,50*mm,leftPadding=0*mm,rightPadding=0*mm,topPadding=0*mm,bottomPadding=0*mm,id='Fcover2',showBoundary=0)
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"):
self._calc()
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
self.setProgressCallBack(self.progresshandler)
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