[reportlab-users] Multi-page formatting in Platypus

Peter Mattingly pmattingly at mail.csuchico.edu
Mon Oct 13 17:12:43 EDT 2008


I need to format several pages with a common header and common body frame.

>From the API ref I see:


A special case document template that will handle many simple documents.
See documentation for BaseDocTemplate. No pageTemplates are required
for this special case. A page templates are inferred from the
margin information and the onFirstPage, onLaterPages arguments to the build
method.

A document which has all pages with the same look except for the first
page may can be built using this special approach.

Which implies that special additional frame definitions, page templates,
etc. Aren't required if all of the pages are the same, which is the case
here.

So I should only need to append header information to new pages.

This does not work. When spanning multiple pages, no new frames are defined
and the text is printed to the canvas directly.

for i in range(40):
text = """Multipage test!!!"""
para = Paragraph(text, style=body_style)
story.append(para)

story.append(PageBreak())

text = """<b>This is a header.</b>"""
para = Paragraph(text, style=header_style)
story.append(para)
story.append(FrameBreak()) #force the writer onto to the next frame (the
body)

for i in range(5):
text = """Multipage test!!!"""
para = Paragraph(text, style=body_style)
story.append(para)

This complies into three pages. The first with my testing paragraphs, the
second with the words "This is a header." on the canvas (e.i. Not in my
previously defined header frame) and the third with my final testing
paragraphs.

I've found a little documentation from the API reference and the examples:
def first_pg(canvas, document):
document.addPageTemplates(default_page_templates)

def next_pg(canvas, document):
document.addPageTemplates(default_page_templates)

pdf.build(story, onFirstPage=first_pg, onLaterPages=next_pg)

but they have not provided a solution as the behavior is unchanged from the
default:

pdf.build(story)

So: How do I define my frames across all of my pages?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20081013/99ff5d89/attachment.html>


More information about the reportlab-users mailing list