PDF Anonymizer CLI
Command-line interface (pdf-anonymizer) for reversible, context-aware anonymization and restoration of PDF, Markdown, plain text, Word (.docx), CSV, and Excel (.xlsx) files. Built on pdf-anonymizer-core.
This tool is a reversible document pseudonymizer, not a legal compliance certificate. Full CLI reference and the companion Anonymization Handbook live at leo-gan.github.io/anonymizer/.
Installation
Install with the provider and format extras you need:
pip install "pdf-anonymizer-cli[google]"
pip install "pdf-anonymizer-cli[ollama]"
pip install "pdf-anonymizer-cli[openai,anthropic]"
pip install "pdf-anonymizer-cli[huggingface,openrouter]"
pip install "pdf-anonymizer-cli[excel,docx,ner]"
Scanned PDF OCR (--ocr) requires the system tesseract binary on PATH.
Environment Variables
The CLI loads a .env file automatically from the current working directory or any parent directory:
- Provider credentials (only for remote models):
GOOGLE_API_KEY,OPENAI_API_KEY,ANTHROPIC_API_KEY,HUGGING_FACE_TOKEN,OPENROUTER_API_KEY OLLAMA_HOST: optional local Ollama URL (defaulthttp://localhost:11434)ANONYMIZER_MAPPING_KEY: optional passphrase for--mapping-passphrase(*.mapping.json.enc)ANONYMIZER_FAKE_SECRET: required seed for--operator TYPE=fakeANONYMIZER_ENCRYPT_SECRET: required secret for--operator TYPE=encrypt
Commands
| Command | Purpose |
|---|---|
pdf-anonymizer run FILE [FILE ...] |
Mask one or more files, write anonymized outputs, mapping (0600), residual report, and risk report. |
pdf-anonymizer deanonymize FILE MAP |
Restore original values locally and write *.deanonymization_stat.json. |
pdf-anonymizer verify FILE |
Scan an already-masked file for leftover structured (or --verify-llm) PII. Report only. |
pdf-anonymizer report FILE |
Score identity-clue linkage clumps in an already-masked file. Report only. |
pdf-anonymizer apply REPORT.json |
Apply accepted leftover hits (--accept-all, --accept, --skip, or interactive TTY) back onto the masked file. |
pdf-anonymizer purge [--root PATH] |
Delete local data/cache/, data/mappings/, data/stats/, and app.log (preserves anonymized/deanonymized documents). |
Common Examples
# Default run (best-speed)
pdf-anonymizer run document.pdf
# Careful profile (also masks indirect identity clues)
pdf-anonymizer run contract.pdf -p best-quality
# Fully local with Ollama (fail-closed via --offline) or regex-only
pdf-anonymizer run notes.md -p best-cost --model-name "ollama/phi4-mini" --offline
pdf-anonymizer run logs.txt --no-llm --offline
# Country filter, operators, keep/deny lists, and encrypted mapping
pdf-anonymizer run notes.pdf contract.pdf \
-p best-quality \
--countries US,GB \
--opt-in all \
--operator CREDIT_CARD=mask \
--operator DATE=generalize \
--keep-list keep.txt \
--mapping-passphrase 'a long secret'
# Native sanitized PDF (reversible --output-pdf, or irreversible --redact) and scanned OCR
pdf-anonymizer run scan.pdf --ocr --output-pdf
# Optional CSV/Excel table k-anonymity + l-diversity / t-closeness report
pdf-anonymizer run roster.csv --no-llm --k 5 --quasi-columns zip,gender --sensitive-column diagnosis
# Restore locally (pass --mapping-passphrase / --source-sha256 / --encrypt-secret as needed)
pdf-anonymizer deanonymize \
data/anonymized/document.anonymized.md \
data/mappings/document.mapping.json
Notes: LLM response caching is off by default (pass --cache to opt in; cached files are mode 0600 with 24-hour TTL). Text and PDF are chunked in memory; CSV, Excel, and Word inputs are capped at 50 MiB (see Large Documents).
Documentation
- CLI Reference — Complete option tables, profiles, and model aliases.
- Recipes & Workflows — Practical end-to-end patterns.
- Troubleshooting — Common errors and fixes.
- Anonymization Handbook — Formal privacy models, file-format leakage, and benchmarks.
Metadata
Release files for pdf-anonymizer-cli 0.33.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pdf_anonymizer_cli-0.33.0.tar.gz | 15.3 kB | With provenance | Details for pdf_anonymizer_cli-0.33.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pdf_anonymizer_cli-0.33.0-py3-none-any.whl | Python 3 | none | any | Details for pdf_anonymizer_cli-0.33.0-py3-none-any.whl |
Total release size: 28.4 kB
Release files / pdf_anonymizer_cli-0.33.0.tar.gz
| Download URL | pdf_anonymizer_cli-0.33.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
654b92abfa7ab0c95bb43b66cb73a05325bebe0ae84190eadea0d136d479184d
|
|
BLAKE2b-256 checksum How to use checksums |
c79c09895669302a4d3dfc2dd3f78acf52ba8a1104e45583985c044ad066fc59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pdf_anonymizer_cli-0.33.0-py3-none-any.whl
| Download URL | pdf_anonymizer_cli-0.33.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ecfdb90adcd16c9d2fab7375e8a7ac91720db959ae6c58ef8df1c46b87f7dfdd
|
|
BLAKE2b-256 checksum How to use checksums |
edf056881096cf51fd29d2c2d2c8307793ed3e5ade25581d291315f7c4bf1dae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for pdf-anonymizer-cli 0.33.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pdf_anonymizer_cli-0.33.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.