[reportlab-users] newbie help
Anil
replicase at gmail.com
Thu Dec 6 22:43:38 EST 2007
Thanks for the help, all.
I want all the pages after 1st page to have 2 columns. I got that part
now by extending the BaseDocTemplate.
However, what I am not understanding is how to draw things on these otherPages.
The 2nd page should have a circle on the top right and so on *until*
the flow ends (or PageBreak). Then, the following page should have a
Rectangle and so son.
I think I can do all of this if I can have access to the Canvas in the
generate() method below. How do I access it? (if you have some
examples, that'll help)
Thanks again.
def generate(self):
buffer = StringIO()
styles = getSampleStyleSheet()
doc = PABTemplate(buffer, pagesize = letter)
Story = [ Spacer(1, 2.0*inch) ]
style = styles["Normal"]
Story.append(PageBreak())
Story.append(Paragraph("Frame one column, "*500,styles['Normal']))
Story.append(PageBreak())
doc.build(Story,
onFirstPage=self.firstPage,
onLaterPages=self.otherPages)
pdf = buffer.getvalue()
buffer.close()
return pdf
def firstPage(self, canvas, document):
"""Produce the first page of the invoice"""
canvas.saveState()
try:
self.drawHeader(canvas, document)
self.drawFooter(canvas, document)
finally:
canvas.restoreState()
def otherPages(self, canvas, document):
"""Produce the first page of the invoice"""
canvas.saveState()
try:
self.drawHeader(canvas, document, frontpage=False)
self.drawFooter(canvas, document)
finally:
canvas.restoreState()
More information about the reportlab-users
mailing list