Re: Get Total Page Count

Tim Roberts <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Organization Providenza & Boekelheide, Inc.
Message-ID <[email protected]>
Mike Hostetler wrote:
> Next newbie question...
>
> How can I get the total page count of the document to be in the PDF? I 
> need a footer with "Page x of Total". Will I have to do a "pageCallback"?

It's trickier than that.  ReportLab does not construct the whole 
document in advance, so it doesn't know the total page count at the 
point it is completing page 1.

There are web sites that describe the process.  Some of them just render 
twice and fill it in the second time, but it's easier to use a "form", 
which is a block of PDF that can be referred to multiple times.  You'd say

     canvas.doForm("PageCount")

in your footer, then at the end of the document you'd fill out the form:

     canvas.beginForm("PageCount")
     canvas.drawString( 0, 0, str(total_pages), ... )
     canvas.endForm()

-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.

_______________________________________________
reportlab-users mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/reportlab-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.