fixed usage help and added -h to command

This commit is contained in:
tobias
2026-02-06 16:17:30 +01:00
parent a8381c1fa5
commit acecd18173
2 changed files with 21 additions and 9 deletions

View File

@@ -19,12 +19,13 @@ Removes personalized SANS “Licensed To …” watermarks (names, emails, hashe
```
3. **Run the sanitizer (auto-creates `<input>_clean.pdf`):**
4.
```bash
# Recommended latest script:
python enhanced_sanitize_pdf.py INPUT_unlocked.pdf
python pdf_sanatizer.py INPUT_unlocked.pdf
```
Use `python pdf_sanatizer.py -h` for CLI help and options.
## Notes
* The tool targets common SANS watermark patterns:
@@ -32,4 +33,3 @@ Removes personalized SANS “Licensed To …” watermarks (names, emails, hashe
* Rotated diagonal overlay using 25-pt fonts,
* Footer lines at 10/18-pt.
* If your course PDFs use different fonts/sizes, adjust the regex patterns inside the script.

View File

@@ -37,11 +37,11 @@ number of watermark segments removed.
This script requires the PyMuPDF (``fitz``) package.
"""
import argparse
import sys
import os
import re
import getpass
from typing import Tuple, Optional
import fitz # type: ignore[import]
@@ -162,11 +162,23 @@ def sanitize_pdf(path: str) -> None:
print(f"Removed {removed} watermark segment(s). Cleaned PDF saved as '{out_path}'.")
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description="Remove SANS-style watermark overlays from the provided PDF. "
"Encrypted PDFs are supported and will trigger a password prompt."
)
parser.add_argument(
"input_pdf",
metavar="INPUT.pdf",
help="Path to the PDF you want sanitized."
)
return parser
def main(argv: list[str]) -> None:
if len(argv) != 2:
print("Usage: python enhanced_sanitize_pdf.py input.pdf")
return
sanitize_pdf(argv[1])
parser = build_parser()
args = parser.parse_args(argv[1:])
sanitize_pdf(args.input_pdf)
if __name__ == "__main__":