[reportlab-users] Platypus headings
timr at probo.com
Fri Dec 15 16:32:04 EST 2006
> On 12/15/06, *Yordanka Budinova* <d.budinova at gmail.com
> <mailto:d.budinova at gmail.com>> wrote:
> 2006/12/15, Saketh <saketh.bhamidipati at gmail.com
> <mailto:saketh.bhamidipati at gmail.com>>:
> I am trying to create a page heading which is written onto
> each page. However, I am having trouble drawing the header
> table before anything else on the page. Instead of being a
> consistent header, everything except the headers are drawn and
> then, on the final page, all of the headers are drawn in
> That is not working for me.
> I have tried to use handle_pageBegin in my template, but the header is
> not drawn to the beginning of each page. It is instead drawn at the
> end of the document.
Where did you get this sample? It's rather confusing.
Think about what you're doing. You're not actually drawing anything to
the canvas in your heading handler. Instead, you are just adding your
page header as yet another flowable to the accumulating story. The
story will not actually be rendered until the whole document is
complete. Thus, your page headers will all be drawn inline with the
other flowables at the end.
Your page header handler should draw directly on the canvas, and not add
anything to the story. If you really need to use Platypus to draw your
headers, you will need to render them during the header, not add them to
You shouldn't override handle_pageBegin. It does many other actions
that must be accomplished, and you're not calling the base class.
Instead, you should pass your heading handler function as the
onFirstPage and onLaterPages parameters when you call "doc.build", or
override beforePageDraw in your template. That's the right way to
handle it. Your page handler will be passed a canvas, and you draw your
header on that canvas.
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the reportlab-users