[reportlab-users] Page Numbering without Platypus
Rob Schall
rschall at callone.net
Mon Aug 28 17:09:46 EDT 2006
I'm currently working on a python class which will automatically
generate contracts for our company. Since they are legal documents, I
need to ensure the page numbers are at the bottom in the X of Y format.
However, everything I've found online refers to using platypus to make
it work. I've made the attempt to do it without, but either I'm
definatly not very good with reportlab, or I'm just missing something.
Currently, the program watches the status of each page and determines if
you are nearing a page end. Once it determines a new page is needed, it
runs the "footer" function which looks like this:
def footer(self, posX, posY):
"""Show Footer Information"""
width, height = self.c._pagesize
width -= self.RightMargin + self.LeftMargin
self.c.drawCentredString(width/2, posY, self.data["footer"])
print ('setPage%d'%self.pageNumber)
self.c.beginForm('setPage%d'%self.pageNumber)
self.c.drawString(width/2,posY-10,"Page 1 of
%d"%self.c.getPageNumber())
self.c.endForm()
self.pageNumber += 1
then a showPage is done and it continues on. Just before the final save,
i have final function that does:
def pageNumbers(self):
for page in range(1,self.pageNumber):
print ("setPage%d"%page)
self.c.doForm("setPage%d"%page)
return 1
Right now, they all appear on the last page. I'm not fully sure why, or
how to fix this. If there's anyone who doesn't think I'm nuts and can
help me out with this, I would GREATLY appreciate it. My head is
exploding. Yay Python. :)
More information about the reportlab-users
mailing list