[reportlab-users] Variant nextPageTemplate's: "chapter" pages with subsequent pages

wandering free walkingreen at googlemail.com
Thu Jan 24 11:09:33 EST 2013


I am in the process of converting the database from pfaf.org (plant for a
future) into a pdf book. I have hit a bit of a stumbling block regarding
pageTemplates.

Each plant may begin on a left or a right aligned page; and may potentially
be two or more pages. I have two templates for the first plant page (left
and right) and also two more templates for the potential subsequent pages.

Currently this is handled as follows (for instance):

for i, plant in enumerate(plants):
#the first plant is printed on a right-hand page
if i % 2 == 0:
template = 'left'
second = 'right'
else:
template = 'right'
second = 'left'

Story.append(nextPageTemplate(template,'*', 'secondary_'+template,
'secondary_'+second))
Story.append(PageBreak())
#append various paragraphs, jumping between frames, etc...

The code (as you can probably tell) works fine for single page plants. It
also works (semi) as expected for multi page plants.

However, as you can also probably see, a two (or four,etc) page plant will
break the template arrangement, because the above code assumes page
position based upon plant number, rather than page number.

I can't see a solution for this in the location of the code above (i.e
during the Story.append cycle) - as at that point I can not tell whether
the plant has used more than one page, and thus what page I am currently
on, as such.

I hoped that I could perhaps tweak the nextPageTemplate structure from my
custom docTemplate, but I can't figure out if this is possible.

Is it? Or is there another solution? Would really appreciate any help. Have
been reading all over, but the best examples I can find don't quite cover
this scenario.

Any questions, please ask. Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20130124/f1e310bb/attachment.html>


More information about the reportlab-users mailing list