[reportlab-users] Dynamic page sizes
v+python at g.nevcal.com
Thu Oct 20 19:53:30 EDT 2011
On 10/19/2011 1:45 AM, Robin Becker wrote:
> The document object has methods to interrogate page number etc etc if
> that's what you want, but usually the way forward is to arrange for a
> number of suitable page templates to exist with the right page sizes,
> frames and decorative onpage etc etc attributes.
> Then in the story you need to start with the right template before the
> first page is started, and when you come to the end of an item you
> prepare for the next page with a sequence like
> story.append(......myflowables for a big poem)
> Usually the start page template is a cover page or some such so make
> that the first template in the list you set up in the document. With
> this kind of approach you shouldn't need to interrogate the current
> document state too much.
> Of course it requires you to know in advance what page size/frame size
> you require. If that is purely content driven then you'll need to use
> the flowables' wrap method to determine what each flowable requires
> etc etc.
OK, this sounds like a reasonable prospect. Let's see if I grasp the
1. create an empty list of templates for each page
2. process each item (poem), creating a flowable, and use the wrap
method, pretending that it has an 8.5x11 page when calling it, and
discovering the actual size. At that point, append a template that has
a page of that size to the template list, and append the flowable to the
set of flowables.
3. create a document, using the list of templates, and the list of flowables
4. build the document
Questions that come to mind,
A. is the flowable still reusable for the document after doing the
pre-processing wrap method? I guess the worst case is that I discard it
and create a new one without calling wrap on it.
B. margins: I'm not clear on whether the wrap size includes the margins
or not, I would guess not, but it seems that with a 3-column layout I
did for something else, that each frame may have had a bit of margin,
even though I tried to specify none. But that layout was using tables
inside the frames, so maybe there was interaction with that as well.
Anyway, I suspect I can get something working with a bit of
experimentation. I'll look into the document object APIs a bit more for
page number info, etc.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the reportlab-users