[reportlab-users] newbie question
John Pywtorak
jpywtora at calpoly.edu
Mon Jun 6 19:29:50 EDT 2005
MICHAEL A KOLAKOWSKI wrote:
>
> Hi Folks,
>
> I'm new to using ReportLab. I have a question which I hope will be
> easy. I'm changing a program to generate a PDF with the same header
> and footer on each page. What is a good way of doing this? The
> program already uses SimpleDocTemplate. I thought, perhaps, one could
> just do this:
>
> doc.build(Story, onFirstPage = myFirstPage, onLaterPages = myFirstPage)
>
> Thus, all the pages should use the same function and be formatted as
> the 'first' page. However, that results in the later pages
> overwriting the header on the first page. You can try this out with
> the examples.py program. I hope I have explained myself clearly,
> thanks for help.
>
> Michael Kolakowski
> Computer Programmer
> Department of Surgery
> University of Nebraska Medical Center
> 402-559-5726
>
>------------------------------------------------------------------------
>
>_______________________________________________
>reportlab-users mailing list
>reportlab-users at reportlab.com
>http://two.pairlist.net/mailman/listinfo/reportlab-users
>
>
Here is exactly what I am using which works great, hope it helps ;-)
self._doc.build(
self._story,
onFirstPage = self._on_page_one,
onLaterPages = self._on_pages,
)
def _on_page_one(self, canvas, doc):
canvas.setAuthor("Academic Records/Accessible")
canvas.setTitle("PolyProgress Degree Audit")
canvas.setSubject("Degree Audit")
self._on_pages(canvas, doc)
def _on_pages(self, canvas, doc):
audit_ver_info = "%s, data refreshed %s %s" % (
self._audit_version,
self._refresh_date,
self._refresh_time,
)
canvas.saveState()
canvas.setFont('Helvetica', 8)
canvas.drawString(0.5 * inch, 10.5 * inch, audit_ver_info)
canvas.drawString(7.5 * inch, 10.5 * inch, "Page %d" % doc.page)
canvas.restoreState()
More information about the reportlab-users
mailing list