Offline CLI tool to securely redact PII from PDF tax-like documents using Python.
- Secure PDF redaction using PyMuPDF
add_redact_annotplusapply_redactions - Default redaction coverage for names, addresses, ZIP codes, SSNs, EINs/TINs, employer state IDs, W-2 control numbers, emails, and phone numbers
- Word-level extraction with line reconstruction to catch multi-token matches, including split SSN and EIN fields
- Optional OCR fallback for scanned pages using
pdf2imageandpytesseract - Local-only processing with no external API calls
Recommended Python version: 3.10
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]OCR fallback also requires native tools:
tesseractmust be installed and available onPATHpopplermust be installed sopdf2imagecan render PDF pages
pii-redact input.pdf --output out.pdf
pii-redact input.pdf --output out.pdf --types ssn,email,phone --ocr-fallback
pii-redact input.pdf --output out.pdf --types name,address,zip,state_id,control_numberDefaults:
- PII types: all supported types
- OCR fallback: disabled
Run tests with:
pytest