[reportlab-users] RE: ActionFlowable usage
Marc Stober
reportlab-users@reportlab.com
Thu, 13 Mar 2003 09:20:35 -0500
Hi Pascal,
I am doing this in a report I've created.
# 1: I've created my own action-flowable-like class as follows:
class TitleChanger(Flowable):
""" Change the section title from page to page. """
def __init__(self, section, title):
self.section = section
self.title = title
Flowable.__init__(self)
def wrap(self, availWidth, availHeight):
""" Doesn't take up any space. """
return (0, 0)
def draw(self):
self.section.title = self.title
Note that "section" should be based on PageTemplate object, as shown below.
Also, I didn't base this on ActionFlowable because, well, when I wrote this
I hadn't discovered ActionFlowable yet; it might be something you can
improve upon.
#2. I've overridden the beforeDrawPage method of PageTemplate something like
this:
class Section(PageTemplate):
def beforeDrawPage(self, canvas, document):
canvas.drawString(...
There are some examples in the ReportLab docs of using the beforeDrawPage
method of PageTemplate to create headers. I'm not familiar with the
handle_page_begin method that you used.
#3. Then I just add my TitleChanger flowable to the list of flowables as I
build it.
Hope this helps. Perhaps the RL staff will respond with an even better
solution.
Marc
mstober@dalbar.com