pdfmasker
Mask sensitive text in PDFs.
Usage
from pdfmasker import mask_pdf
pdf_bytes = open("paystub.pdf", "rb").read()
result = mask_pdf(pdf_bytes, patterns=["Jane Doe", "123-45-6789"])
result.pdf # bytes — the masked PDF
result.counts # {"Jane Doe": 2, "123-45-6789": 1}
mask_with controls the replacement string; omit it (or pass None) to use the default mask (a run of X matching
each target's length):
mask_pdf(pdf_bytes, patterns=["Jane Doe"], mask_with="[REDACTED]")
Errors raise pdfmasker.MaskError.
Masking backends
Text replacement is available through two independent implementations. mask_pdf uses the first one by default; the
second is opt-in.
-
Bundled binary (default).
mask_pdfandMasker()drive a compiled Go engine over a subprocess. It works out of the box with the installed wheel and needs no extra dependencies. -
In-process (pikepdf).
PikepdfTextLayerStrategyedits the PDF's content streams directly in Python, avoiding the per-call subprocess overhead. It is an optional dependency:pip install pdfmasker[pikepdf]
from pdfmasker import Masker from pdfmasker.strategies.pikepdf import PikepdfTextLayerStrategy masker = Masker(strategies=[PikepdfTextLayerStrategy()]) result = masker.mask(pdf_bytes, patterns=["Jane Doe"])
Both accept the same patterns and mask_with, and return the same MaskResult. The bundled binary is the more
battle-tested path; the pikepdf backend trades that maturity for lower latency and a pure-Python dependency. Without the
pikepdf extra installed, using the in-process strategy raises pdfmasker.MissingDependencyError.
Contributing
The architecture, repository layout, setup, dev commands (make help), the build/cross-build model, and the release
flow all live in CONTRIBUTING.md.
Metadata
Release files for pdfmasker 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pdfmasker-0.0.2.tar.gz | 33.3 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pdfmasker-0.0.2-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| pdfmasker-0.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| pdfmasker-0.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| pdfmasker-0.0.2-py3-none-macosx_11_0_x86_64.whl | Python 3 | none | macOS 11.0+ x86-64 | Details |
| pdfmasker-0.0.2-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
Total release size: 45.6 MB
Release files / pdfmasker-0.0.2.tar.gz
| Download URL | pdfmasker-0.0.2.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c267fc133fde9f1a051737848b67f42824e8a3fb018fa0e45b73253098f0506b
|
|
BLAKE2b-256 checksum How to use checksums |
0f931ac8f64efc7e562b77879c1cb941d791d168f5fd8fa7ccca30c3eb8ad925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pdfmasker-0.0.2-py3-none-win_amd64.whl
| Download URL | pdfmasker-0.0.2-py3-none-win_amd64.whl |
|---|---|
| Size | 9.2 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2a9b74b95de2c91aabdfdf0a4d268b40a2c500702ea2b48915ce48c7401bd9d1
|
|
BLAKE2b-256 checksum How to use checksums |
d0a5d00e3c4efc77963fddbea0d3761de88cdb60a70b3e42b33606508443ce63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pdfmasker-0.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pdfmasker-0.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 9.2 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
a80b158cfc21da2164ac9b27a1f25cd69ffa5acd8fa84d2859794172ca0a31d7
|
|
BLAKE2b-256 checksum How to use checksums |
014e52698294640aab884f695474198db5716ae412f1de70fb55bf90edca3865
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pdfmasker-0.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pdfmasker-0.0.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
c5025dada65d6c3832b0073fd342086bc4e8de50eb755f674b3c3c7c4e055b17
|
|
BLAKE2b-256 checksum How to use checksums |
a82bcf969d90ad70ecba94512e4d03d984ca9db6cf7daa7a26ef2676e7ce41e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pdfmasker-0.0.2-py3-none-macosx_11_0_x86_64.whl
| Download URL | pdfmasker-0.0.2-py3-none-macosx_11_0_x86_64.whl |
|---|---|
| Size | 9.7 MB |
| Tags | Python 3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
ca0543d273f4e8625f120a6c9cb1a9f58a8b30a92cef0869f5700cfd2a718bec
|
|
BLAKE2b-256 checksum How to use checksums |
70c12c44248df8bd0391b681cccd698d5f090b87242289e7704b41b7a0063bab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pdfmasker-0.0.2-py3-none-macosx_11_0_arm64.whl
| Download URL | pdfmasker-0.0.2-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 9.1 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
bee296f2c01886d62412cacabfe357e008e42dba5596d8e6b4c0ca2bbec5bf2f
|
|
BLAKE2b-256 checksum How to use checksums |
73bc3c1a11120e73e7bb2e2ef761b939600c1b72f52a124d4883f9d5fa504738
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|