Search code examples
pythonpython-2.7pypdf

PyPDF2: how to add a footer to a pdf?


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?


Solution

  • PyPDF2 does not have a footer function.

    You can add a footer by

    1. Creating a single PDF page that only contains the footer, e.g. via reportlab
    2. Adding that page as an overlay (or as a watermark) - see docs