pdfmasker
With this library you can mask sensitive text in PDFs or basically change any text in your PDF files.
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]")
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.3
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.3.tar.gz | 34.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pdfmasker-0.0.3-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| pdfmasker-0.0.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| pdfmasker-0.0.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| pdfmasker-0.0.3-py3-none-macosx_11_0_x86_64.whl | Python 3 | none | macOS 11.0+ x86-64 | Details |
| pdfmasker-0.0.3-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.3.tar.gz
| Download URL | pdfmasker-0.0.3.tar.gz |
|---|---|
| Size | 34.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6737af54bd20d774bfbb715f163f3f8df1a65743e1934bb56dec7bf999406d0
|
|
BLAKE2b-256 checksum How to use checksums |
32e1c5fcaf9479b634ceb568316dbebac1b60c2d14b3b4ef59da0c6a7db79992
|
| 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.3-py3-none-win_amd64.whl
| Download URL | pdfmasker-0.0.3-py3-none-win_amd64.whl |
|---|---|
| Size | 9.2 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
62f977cf8ee56dabda2b90aad8b02a8431a863820c7748bbcfedff71ff47b17e
|
|
BLAKE2b-256 checksum How to use checksums |
2cdb7a91c82e26fb4a8cdff4fe4bfe7b7fcbd7f0872e5cdbeda4e07a8ce2cb70
|
| 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.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pdfmasker-0.0.3-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 |
c4171d383c2b585a35754c58d6f603d4216b046237370fe7eee244ca9c81a1df
|
|
BLAKE2b-256 checksum How to use checksums |
310bb4fac13143c02e799ff55d144d0a7fa53aafb9e344decf4505793979c248
|
| 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.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pdfmasker-0.0.3-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 |
55f155b954b739d3adee7061251acd8c70217ce5713af7ef6eebe6cf680c4d4e
|
|
BLAKE2b-256 checksum How to use checksums |
c3b0a8890487f3cf909acdf3fcce3badb6cdcd68619ede6ddadc7cbf5204b3cd
|
| 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.3-py3-none-macosx_11_0_x86_64.whl
| Download URL | pdfmasker-0.0.3-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 |
1413da8bab80c371437d127a2337ba746632194c51f915ba3e2d122f019ee0d9
|
|
BLAKE2b-256 checksum How to use checksums |
1ca57f564a25c36cb58d18d03c9c68c1d11cb37cb12dfd511fff9123976f2388
|
| 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.3-py3-none-macosx_11_0_arm64.whl
| Download URL | pdfmasker-0.0.3-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 |
94e3f7f2e9e04b064e2719481db8b73736d6c47813bce2adebad970efbfb419e
|
|
BLAKE2b-256 checksum How to use checksums |
aaf61b663b2cf48e407be22f67bdabe09164fa2d2543ba0505683e2dc385d571
|
| 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}
|