[reportlab-users] Re: Playpus "Total pages" before PDF gets generated.

Henning von Bargen H.vonBargen at triestram-partner.de
Fri Dec 3 03:19:16 EST 2004


> Date: Thu, 2 Dec 2004 13:10:52 +0200
> From: bo at bitute.b4net.lt
> Subject: Re: [reportlab-users] Re: Playpus "Total pages" before PDF
> 	gets	generated.
> To: reportlab-users at reportlab.com
> Message-ID: <20041202111052.GA24626 at bitute.b4net.lt>
> Content-Type: text/plain; charset=utf-8
> 
> On Thu, Dec 02, 2004 at 09:17:38AM +0100, Henning von Bargen wrote:
> > On the first run, total_pages is unknown and thus the page header shows
> > wrong values.
> > On the second run, total_pages has the correct value, so the header is
> > correct.
> 
> Hmm. Do you mean that document should be processed TWICE?

Yes, that's the only fool-proof way to do it.
Theoretically, it could even happen that you'd have to process the document
three times, i.e. if you reference the total number of pages somewhere
in your document text:
On the first run, the best known value is 1 (=one character),
after the first run you know that you need 10 pages,
on the second run, the best known value is 10 (=two characters),
so it may happen that now the line containing the total number of pages
reference
must be wrapped, possibly causing different page breaks and, in rare cases,
your document could now need 11 pages.
So multibuild would do a third run.

You'd need multibuild anyway if you wanted to include a TOC
at the start of the document.

Other programs like LaTeX do it the same way.

Henning


More information about the reportlab-users mailing list