[reportlab-users] number of pages
Bogdan Maryniuk
bo at bitute.b4net.lt
Tue Jun 28 08:32:38 EDT 2005
On Tue, Jun 28, 2005 at 02:14:12PM +0200, Michael Schulz wrote:
> i have a SimpleDocTemplate document and would like to output on the
> first page the total number of pages the document has when it is built.
>
> How could i achieve this?
Almost similar as to provide "Page 1 of 100", "Page 2 of 100". This seems to
be tricky enough. AFAIK, 1.19 version of RL does not really knows how much pages
it will produce. Maybe newest knows already, but I am not aware of this.
However, at least one (ugly) workaround still exists:
1. Leave empty place, like: "Pages 1 of ".
2. Process document and count the pages.
3. Process document AGAIN and write these numbers on that place in the forms.
Caveat: if you want right-justified or centered text, you may fail aligning it
properly, since you don't know exact width of the currently placed text. One
more workaround for this is to process the document three times: first, you
know how much pages, second, you know the width of the text for each page
and finally you paint this stuff properly. :-)
Although I am really intersted what Robin would reply on this...
--
暮
Some performers on television appear to be horrible people, but when
you finally get to know them in person, they turn out to be even worse.
-- Avery
More information about the reportlab-users
mailing list