Skip to content

Batch-stamp bottom-only footers on PDFs (path left, Page X/N right). Handles rotations; skips flipped scans. Outputs to PDF_with_Footer/.

License

Notifications You must be signed in to change notification settings

WINEEL/pdf-footerizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Bottom Footer Stamper

Add bottom-only footers to PDFs in bulk. Works well on scanned PDFs and mixed rotations.

Left footer shows the relative file path. Right footer shows Page i/N.

Pages that appear internally flipped are skipped to avoid stamping at the visual top.

What this tool does

  • Recursively finds PDFs starting from the current working directory
  • Places a bottom-only footer inside each page’s visible area (CropBox)
  • Handles /Rotate 0, 90, 180, 270
  • Skips pages that look internally flipped in their content stream
  • Keeps originals unchanged, writes results to PDF_with_Footer/ with _footer.pdf suffix
  • Ignores PDF_with_Footer/ when scanning so it never reprocesses its own output

Project structure

You can run this in any folder that contains PDFs, including nested subfolders. Example:

your-docs-root/
  contracts/
    2023/
      NDA.pdf
      SOW.pdf
  receipts/
    jan/
      store-a.pdf
      store-b.pdf
  notes.pdf
  main.py
  requirements.txt
  .gitignore
  README.md
  • The script scans everything under the folder where you run it.
  • Processed files are written to:
    your-docs-root/PDF_with_Footer/<original-name>_footer.pdf
    
  • The input layout can be any set of folders. You do not need special names like Lesson 011.

If you want to process a different tree, either:

  • Copy main.py into that folder and run it there, or
  • Open a terminal in that folder and run python3 main.py from there.

Installation

Requirements

  • Python 3.9 or newer
  • pip available in your path

macOS and Linux

# 1) Clone your repo
git clone https://github.com/<your-username>/pdf-bottom-footer-stamper.git
cd pdf-bottom-footer-stamper

# 2) Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate

# 3) Install dependencies
pip install -r requirements.txt

Windows (PowerShell)

# 1) Clone your repo
git clone https://github.com/<your-username>/pdf-bottom-footer-stamper.git
cd pdf-bottom-footer-stamper

# 2) Create and activate a virtual environment
py -3 -m venv .venv
.venv\Scripts\Activate.ps1

# 3) Install dependencies
pip install -r requirements.txt

Windows (CMD)

git clone https://github.com/<your-username>/pdf-bottom-footer-stamper.git
cd pdf-bottom-footer-stamper

py -3 -m venv .venv
call .venv\Scripts\activate.bat

pip install -r requirements.txt

Unix variants (BSD, WSL, etc.)

Use the same steps as macOS and Linux. Replace python3 with the correct Python command if needed.

Usage

  1. Place main.py in the root folder that contains the PDFs you want to stamp.
  2. Open a terminal in that folder and run:
python3 main.py

On Windows you can also use:

py -3 main.py

Output will appear in a new folder:

./PDF_with_Footer/<original-name>_footer.pdf

Clean rebuild

If you change footer settings in main.py or want to regenerate everything:

  • Delete the PDF_with_Footer/ folder
  • Run python3 main.py again

The script never modifies originals.

Example log

Processing: contracts/2023/NDA.pdf
Processing: receipts/jan/store-a.pdf
   ↪︎ skipped page 2 (reflected/flip matrix in content)
Processing: notes.pdf
...
Best-effort stamping complete (bottom-only).
Check the folder: /full/path/to/PDF_with_Footer

What the footer looks like

receipts/jan/store-a.pdf                                     Page 2/5
  • The left side shows the PDF’s relative path from the root where you ran the script.
  • The right side shows Page i/N.

Configuration and tweaks

Open main.py if you want to adjust:

  • margin_x, margin_y for spacing from edges
  • Trimming length of the left text (the relative path)
  • Font family and size used by ReportLab

Re-run after changes. If you want to remove previous results, delete PDF_with_Footer/ and run again.

Notes and limits

  • Some scanned pages are stored upside down without a /Rotate flag. The script uses a best effort check on the content stream. If it detects a likely flipped page, it skips stamping that page to avoid a top footer.

  • If you must stamp every page, normalize scans first, then run the stamper:

    macOS and Linux

    brew install ocrmypdf      # macOS with Homebrew
    ocrmypdf --rotate-pages --rotate-pages-threshold 12 input.pdf fixed.pdf

    Windows

    • Install OCRmyPDF from the official docs
    • Then run the same ocrmypdf command in PowerShell or CMD
  • Very old PyPDF2 versions behave differently. The repo pins versions in requirements.txt that work well.

Troubleshooting

  • No output files: ensure you are running from the correct folder and that there are PDFs beneath it.
  • Footer at the top: those pages are likely internally flipped without rotation metadata. The script will try to detect this and skip. Pre-normalize with OCRmyPDF if you want to stamp them.
  • Text too long: paths are trimmed. You can shorten deep folder names or adjust the trim logic in code.
  • Permission errors on Windows: if PowerShell blocks scripts, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned in an elevated PowerShell window.

Requirements

See requirements.txt:

PyPDF2>=3.0.0
reportlab>=4.0.0

License

MIT

Author

Wineel Wilson Dasari

About

Batch-stamp bottom-only footers on PDFs (path left, Page X/N right). Handles rotations; skips flipped scans. Outputs to PDF_with_Footer/.

Topics

Resources

License

Stars

Watchers

Forks

Languages