fixed usage help and added -h to command
This commit is contained in:
@@ -19,12 +19,13 @@ Removes personalized SANS “Licensed To …” watermarks (names, emails, hashe
|
|||||||
```
|
```
|
||||||
|
|
||||||
3. **Run the sanitizer (auto-creates `<input>_clean.pdf`):**
|
3. **Run the sanitizer (auto-creates `<input>_clean.pdf`):**
|
||||||
4.
|
|
||||||
```bash
|
```bash
|
||||||
# Recommended latest script:
|
python pdf_sanatizer.py INPUT_unlocked.pdf
|
||||||
python enhanced_sanitize_pdf.py INPUT_unlocked.pdf
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Use `python pdf_sanatizer.py -h` for CLI help and options.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
* The tool targets common SANS watermark patterns:
|
* 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,
|
* Rotated diagonal overlay using −25-pt fonts,
|
||||||
* Footer lines at 10/18-pt.
|
* Footer lines at 10/18-pt.
|
||||||
* If your course PDFs use different fonts/sizes, adjust the regex patterns inside the script.
|
* If your course PDFs use different fonts/sizes, adjust the regex patterns inside the script.
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ number of watermark segments removed.
|
|||||||
This script requires the PyMuPDF (``fitz``) package.
|
This script requires the PyMuPDF (``fitz``) package.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import getpass
|
import getpass
|
||||||
from typing import Tuple, Optional
|
|
||||||
|
|
||||||
import fitz # type: ignore[import]
|
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}'.")
|
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:
|
def main(argv: list[str]) -> None:
|
||||||
if len(argv) != 2:
|
parser = build_parser()
|
||||||
print("Usage: python enhanced_sanitize_pdf.py input.pdf")
|
args = parser.parse_args(argv[1:])
|
||||||
return
|
sanitize_pdf(args.input_pdf)
|
||||||
sanitize_pdf(argv[1])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user