[reportlab-users] PLATYPUS and page footers with page-dependent
content
Chad Miller
chad_miller at symantec.com
Wed Sep 7 14:57:55 EDT 2005
Page 62+63 of the User Guide say that one can use BaseDocTemplate.afterPage()
to add to a page, e.g., "the first and last word on the page of a dictionary."
Well, I'm darned if I could figure out how. My goal was to add after "Page N"
the name of the section I'm in. I found a way to accomplish it, but not any
way that the User Guide hints at. I offer it as a recipe for users wishing to
do the same:
I created a new class, NextTitle, that extends Flowable. Its height and width
are zero, and it takes parameters that describe the section. The draw()
method of NextTitle creates or updates a list inside the canvas object,
self.canv .
When the onPage attribute of the PageTemplate is called, it has access to the
canvas object, and it takes the information needed for the footer from my
attribute in canvas.
Some guidelines for usage: Put the NextTitle object before any PageBreaks or
Spacers. Then, insert the spacers and the title object. (This rigid order
may be avoidable with use of "keepWithNext", but I haven't yet bothered to
figure out how to use that yet.)
- chad
More information about the reportlab-users
mailing list