Olga Donin
Olga Donin

Reputation: 69

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

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

Upvotes: 1

Views: 150

Answers (1)

Denis
Denis

Reputation: 570

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)

Upvotes: 1

Related Questions