[reportlab-users] Page 1 of 3

Robin Becker robin at reportlab.com
Fri Jan 26 12:55:15 EST 2007


Michael Hipp wrote:

> On a report built using SimpleDocTemplate, is there some easy to get a

> "Page 1 of 3" in the footer? The current page number is easy to get with

> 'doc.page' but there seems to be no "doc.pages" to get the finished page

> count.

>

.....
The onPageEnd stuff allows you to use canvas level primitives to decorate the
page. Assume you have a form called pageTotal then your page decorator does
something like

canvas.doForm('pageTotal')

at the appropriate place on the page. Note that the form need not be defined
when you reference it.

At the end of the document build you need to set up the form using more canvas
level operations.

canvas.beginForm('pageTotal')
canvas.saveState()

......
canvas.drawString(x,y,str(nPages))
canvas.restoreState()
canvas.endForm()

--
Robin Becker


More information about the reportlab-users mailing list