Reportrlab - How to add a table at the beginning of each page

138 views Asked by At

I am using ReportLab to generate a pdf. I have a one-row table t. I need add it at the beginning of each page. How I can do it?

Thanks

1

There are 1 answers

0
Denis On

You can use the onFirstPage and onLaterPages keyword arguments to the DocTemplate.build function for this.

They are called during layout before the pages are drawn. You can pass any function with the following signature:

def myOnFirstPage(canvas, document):
    ...

def myOnLaterPages(canvas, document):
    ...

Use them with

doc = SimpleDocTemplate('file.pdf')
doc.build(story, onFirstPage=myOnFirstPage, onLaterPages=myOnLaterPages)