[reportlab-users] SimpleDocTemplate and clever in document numbering

Andy Robinson andy at reportlab.com
Tue Jun 15 11:43:01 EDT 2010


On 15 June 2010 13:44, Laszlo KREKACS <laszlo.krekacs.list at gmail.com> wrote:

> Dear list,

>

> My problem is obvious: I would not like to depend on page numbering

> to decide where ends the main document, simply because I cant be

> sure its always 6 page long.


I think you need to move beyond SimpleDocTemplate, and create your own
BaseDocTemplate. You can then attach different PageTemplates to it
for each different section (body, appendix etc), and each of these can
have a callback registered to decorate the page. Chapter 5 covers how
to set these up.

When you start it will use the first template supplied. Let's call
this the 'main' template. Then, after the 'main' content, you add a
NextPageTemplate e.g.

story.append(.....stuff for the main document.....)

from reportlab.platypus.doctemplate import NextPageTemplate, NextPage
story.append(NextPageTemplate("appendix"))
story.append(NextPage())

story.append(.....stuff for the appendix.....)

This tells the engine to change from using the "main" page template to
the "appendix" page template on the next page break. Then you will
probably add a page break. Thereafter, all your content will appear
in "appendix" pages, which can have their own methods to decorate the
page.

I hope this helps!

- Andy


More information about the reportlab-users mailing list