[reportlab-users] PageTemplate's onPageEnd

Nicholas Wieland nicholas_wieland at yahoo.it
Fri Aug 5 03:09:35 EDT 2005


I've added canvas.saveState () and canvas.restoreState (), and drawing a big canvas.rect instead of a little string, but again, nothing happens.
I'm quite confused because I don't know what's wrong with this :/
 
This is the whole thing. It uses some external functions and some external flowables, but if I understood it correctly, onPageEnd should draw the footer at build() time. 
 
 def pageFooter (canvas, document):
  canvas.saveState ()
  canvas.setFillColorCMYK (10, 10, 10, 10)
  canvas.rect (0, 0, defaultPageSize [0] - 12, defaultPageSize [1], fill = 1, stroke = 0)
  canvas.restoreState ()

def generate (IReportObj, ptf_code, reference_date):
  """ Generates the report. """
  # fetch portfolio data
  ptf_data = ptfData (IReportObj, ptf_code, reference_date)
  # instantiates flowables
  cover_flowable = Cover (ptf_data ['dossier_number'])
  pb_head_flowable = PageHeader (
    ptf_data ['dossier_number'], reference_date, "Performance & Benchmark Composition")
  p_table = Table (performance (IReportObj, ptf_code, reference_date), style = performance_style)
  p_table.hAlign = 'CENTRE'
  bc_table = Table (benchmarkComposition (IReportObj, reference_date, ptf_code), style = bench_comp_style)
  # instantiates frames
  cover_frame = Frame (x1 = 0, y1 = 0, width = defaultPageSize [0], height = defaultPageSize [1])
  pb_header_frame = Frame (
    x1 = 0, y1 = defaultPageSize [1] - 80, width = defaultPageSize [0], height = 80)
  p_table_frame = Frame (
    x1 = 50, y1 = defaultPageSize [1] // 3,
    width = defaultPageSize [0], height = defaultPageSize [1] // 3)
  bc_table_frame = Frame (
    x1 = 50, y1 = defaultPageSize [1] // 3,
    width = defaultPageSize [0], height = defaultPageSize [1] // 3)
  # instantiates pagetemplates
  cover_page = PageTemplate (frames = [cover_frame])
  pb_page = PageTemplate (frames = [pb_header_frame, p_table_frame, bc_table_frame], onPageEnd=pageFooter)
  # instantiates the whole document
  report_doc = BaseDocTemplate (filename = ptf_code + reference_date.replace ('/', '') + '.pdf',
    pageTemplates = [cover_page, pb_page])
  # create a doc story
  report_story = []
  report_story.append (cover_flowable)
  report_story.append (pb_head_flowable)
  report_story.append (Spacer (width = defaultPageSize [0], height = 40))
  report_story.append (p_table)
  report_story.append (Spacer (width = defaultPageSize [0], height = 40))
  report_story.append (bc_table)
  # build the document
  report_doc.build (report_story)
 
 
TIA,
  ngw

		
---------------------------------
Yahoo! Mail: gratis 1GB per i messaggi, antispam, antivirus, POP3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20050805/e3daad32/attachment.html


More information about the reportlab-users mailing list