[reportlab-users] Setting the start point of multi page table

Albert Leibbrandt albertl at compuscan.co.ug
Mon Jun 28 07:53:41 EDT 2010


I have a pdf report generated using the SimpleDocTemplate. the report
generates a table that spans multiple pages.
Each page has a some descriptive text and a logo using the onLaterPages
parameter in doc.build
what's happening is the table is being layered over the logo on all but
the first page. I can start the table in a specific position but once it
starts spanning pages I have no idea how to assign a starting position.
here is an extract of my code

doc = SimpleDocTemplate("test.pdf")
Story = [Spacer(1, mm * 60)]
#populate story with first page

record_data = []
for var1, var2, var3, var4, var5 in cursor.fetchall():
Story.append(PageBreak())
Story.append(Spacer(1, mm * 15))
Story.append(Paragraph(var1, heading1))
Story.append(Spacer(1, mm * 5))
Story.append(Paragraph(var2, description))
Story.append(Spacer(1, mm * 5))
record_data.append([Paragraph('Header 1', grid_header),
Paragraph('Header 2', grid_header), Paragraph('Header 3', grid_header),
Paragraph('Header 4', grid_header), Paragraph('Header 5', grid_header)])

record_data.append([Paragraph(var1, grid), Paragraph(var2, grid),
Paragraph(var3, grid), Paragraph(var4, grid), Paragraph(var5, grid)])

t = Table(record_data, style=[('GRID', (0, 0), (-1, - 1), 0.5,
colors.HexColor('#00204E'))], colWidths=[65, 220, 50, 50, 40])
Story.append(t)

doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)


myFirstPage and MyLaterPages are functions that use the canvas to draw
the page header and footer.

I am using reportlab 2.3 with python 2.5.4

Any advice would be greatly appreciated.

Cheers
Albert





More information about the reportlab-users mailing list