PyPDF2: how to add a footer to a pdf?
Question:
In PyPDF2, how to add a footer to every page of a pdf file? Do I have to do something like
page5 = reader.pages[4]
page5.mediabox.right = page5.mediabox.right / 4
page5.mediabox.top = page5.mediabox.top / 4
writer.add_page(page5)
or is there a predefined footer function?
Answers:
PyPDF2 does not have a footer function.
You can add a footer by
- Creating a single PDF page that only contains the footer, e.g. via reportlab
- Adding that page as an overlay (or as a watermark) – see docs
In PyPDF2, how to add a footer to every page of a pdf file? Do I have to do something like
page5 = reader.pages[4]
page5.mediabox.right = page5.mediabox.right / 4
page5.mediabox.top = page5.mediabox.top / 4
writer.add_page(page5)
or is there a predefined footer function?
PyPDF2 does not have a footer function.
You can add a footer by
- Creating a single PDF page that only contains the footer, e.g. via reportlab
- Adding that page as an overlay (or as a watermark) – see docs