[reportlab-users] number of pages

Andy Robinson andy at reportlab.com
Tue Jun 28 09:56:52 EDT 2005


Bogdan Maryniuk wrote:
> On Tue, Jun 28, 2005 at 02:09:30PM +0100, Andy Robinson wrote:
> 
>>A similar technique lets you draw a table of contents on page 1
>>if you can accept a maximum-fixed-size rectangle for your document.
> 
> 
> How do you know *exact* width for that m-f-s rectangle then? 

You don't.  You approximate.  If you want real accuracy
you must use multi-pass rendering.

For the table-of-contents problem, there have been
many cases where I know that, for example, there are
the same ten sections, it's just their page numbers
which vary.  So I can define a rectangle on page 1
which will definitely contain them.  You can easily
get 30 lines of text in a nice cover, and extra lines
down below don't hurt.

For a general book rendering system where the TOC might
have n chapters and the TOC might span several pages,
you must do multipass.


For the simple "page X of Y" case, I would right-align Y
so that it fit the correct distance from "of ", but accept
that it will not be perfectly centred on the page.

It's your choice.  For real time business documents on
the web, our customers generally prefer speed to absolute
perfection.

> Would be nice get working code, solving the question above. Thanks.

I will try an example of each approach...

- Andy






More information about the reportlab-users mailing list