[reportlab-users] ActionFlowable usage for datadriven headers
reportlab-users@reportlab.com
reportlab-users@reportlab.com
Fri, 14 Mar 2003 09:03:17 +0100 (CET)
Hi
here is the version of Marc but using
ActionFlowable for trigger header change :
*add a handle to be called by Action flowable to BaseDocTemplate
class REPORT(BaseDocTemplate):
def handle_setPageTitle(self,text):
self.pageTemplate.Title=text
* needed in the call below redefined instead of imported
def _doNothing(canves,doc): pass
* call the super constructor and adds a Title property
* fill the before drawpage method
class drivenPage(PageTemplate):
def __init__(self,id=None,frames=[],onPage=_doNothing,
onPageEnd=_doNothing ):
PageTemplate.__init__(self,id,frames,onPage,onPageEnd)
self.Title=''
def beforeDrawPage(self, canv,doc):
canv.saveState()
canv.setFont('Helvetica',10)
canv.drawString(1.1*cm ,28.5*cm,self.Title)
canv.line(1 * cm,28 * cm,20 * cm, 28 * cm)
canv.restoreState()
**next in the story list call as
actionheader=ActionFlowable(action=('setPageTitle',TEXT)
story.append(actionheader)
maybe the base class PageTemplate could have the Title property
natively, because it is rather often needed and does have its place
here and not in frames for instance
pascal