[reportlab-users] RE: ActionFlowable usage

reportlab-users@reportlab.com reportlab-users@reportlab.com
Thu, 13 Mar 2003 16:50:08 +0100 (CET)


Hi Marc, thanks for answer,

I'll try it.


in the meantime, I have found this other solution,
which I don't know is good or not, because it can end up
with a lot of page templates added to the doctemplate :



def drivenheader(text=''):
	def myfunction(canv,doc):
			canv.saveState()
			canv.setFont('Helvetica',10)
			canv.drawString(1.1*cm ,28.5*cm,text)	
			canv.line(1 * cm,28 * cm,20 * cm, 28 * cm)
			canv.restoreState()
			
	return myfunction

this returns a sort of closure function with text engraved in it

next, in the flow of story list building, when I want next page to change
header, I add this (note MyFrame does not change):


Mydoc.addPageTemplates(PageTemplate(id=VAR,
frames= [MyFrame],onPage=drivenheader(TEXT)))

actionheader=NextPageTemplate(VAR)
(equivalent to =ActionFlowable(action=('nextPageTemplate',VAR)))

text.append(actionheader)
text.append(PageBreak())
		

ie  I add a new page template  to the doctemplate, just before I want it for 
nextpage


best regards 

pascal