[reportlab-users] Using fixed frames for some parts of the page

Jordi Gutiérrez Hermoso jordigh at octave.org
Thu Sep 1 22:24:48 EDT 2011


I'm using a class derived from PageTemplate and defining its frames in
the init portion. However, I want some of those frames to be
pre-filled with stuff. I tried something like

def __init__(self):
frames = list()

## Four frames for the fixed part of the page
frames.append(Frame(5.1*inch, 6.8*inch,
5.5*inch, 0.8*inch, showBoundary=1))
frames.append(Frame(5.1*inch, 5.5*inch,
4.5*inch, 1.2*inch, showBoundary=1))
frames.append(Frame(0.4*inch, 0.4*inch,
5.1*inch, 0.7*inch, showBoundary=1))
frames.append(Frame(5.6*inch, 0.4*inch,
4.6*inch, 0.7*inch, showBoundary=1))

## Three frames for the five flowable graphs
frames.append(Frame(0.4*inch, 5.5*inch,
4.5*inch, 2*inch, showBoundary=1))
frames.append(Frame(0.4*inch, 1.2*inch,
4.5*inch, 3.9*inch, showBoundary=1))
frames.append(Frame(5.6*inch, 1.2*inch,
4.5*inch, 3.9*inch, showBoundary=1))

PageTemplate.__init__(self, "graph_page", frames)

def beforeDrawPage(self, canvas, doc):
drawFancyHeader(canvas,doc)
story = list()
ss = getSampleStyleSheet()['Normal']
for i in range(0,4):
p = Paragraph("trolololololololol", ss);
self.frames[i].add(p, canvas)
self.frames[i].add(FrameBreak(), canvas)

but this is giving me

NotImplementedError:
handle_pageBegin args=()

because FrameBreak apparently is a flowable that doesn't override this
method.

How can I accomplish what I want? Is it possible to have fixed frames
that are pre-filled? I could manually lay out their contents instead,
but it would be a tad too laborious, and not flexible enough for what
I want to do.

TIA,
- Jordi G. H.


More information about the reportlab-users mailing list