PdfRedact
A robust PDF redaction library that securely removes sensitive information while preserving document integrity.
Features at a Glance
🔒 Comprehensive Redaction
- Handles both visual content and searchable text layers
- True removal of sensitive information
⚙️ Flexible Configuration
- Adjustable image quality (DPI)
- Configurable text handling (invisible or removed)
- Cross-platform support (Windows & Unix)
🛠️ Professional-Grade Tools
- High-resolution image processing
- Precise coordinate-based redaction
- Document searchability preservation
Installation
pip install pdfredact
Dependencies
- Python 3.10+
- Poppler (PDF to image conversion)
- Pillow (Image processing)
- ReportLab (PDF generation)
Windows Setup
Windows users must install Poppler and either:
- Set the
POPPLER_PATHenvironment variable - Provide the path explicitly in function calls
How It Works
The redaction process follows a secure two-step approach:
-
Image Layer Redaction 📸
- Converts PDF pages to high-resolution images
- Applies black rectangles to specified areas
- Maintains quality through configurable DPI
-
Text Layer Processing 📝
- Generates a new searchable text layer
- Removes or obscures text in redacted regions
- Preserves document searchability
Usage Example
from pdfredact import redact_pdf_to_images, build_text_redacted_pdf
# Define redaction areas using page coordinates
redactions = [{
"bounds": {
"left": 100,
"right": 200,
"top": 50,
"bottom": 75
},
"tokensJsons": [...], # Token information
"rawText": "sensitive text"
}]
# Step 1: Generate redacted images
redacted_images = redact_pdf_to_images(
pdf_bytes=pdf_content,
pawls_pages=page_data,
page_annotations=[redactions],
dpi=300
)
# Step 2: Create final PDF with redacted text layer
build_text_redacted_pdf(
output_pdf="redacted_document.pdf",
redacted_images=redacted_images,
pawls_pages=page_data,
page_redactions=[redactions],
dpi=300,
hide_text=True # Text remains copyable but invisible
)
Best Practices
📋 Quality Assurance
- Use 300+ DPI for optimal output quality
- Verify redactions through:
- Visual inspection
- Copy/paste testing
- Text extraction tool verification
⚠️ Known Limitations
- Processing time scales with DPI and document size
- Large documents require substantial memory
- Image-based PDFs need special handling
Security Advisory
⚠️ Important: Always verify redacted documents thoroughly. The PDF format is complex and support can vary. Multiple verification methods are recommended for sensitive materials.
Disclaimer: We are not liable for consequences arising from improperly redacted PDFs.
License
pdfredact is distributed under the terms of the MIT license.
Metadata
Release files for pdfredact 0.0.6
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 |
|---|---|---|---|---|
| pdfredact-0.0.6.tar.gz | 401.3 kB | Without provenance | Details for pdfredact-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pdfredact-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for pdfredact-0.0.6-py3-none-any.whl |
Total release size: 408.0 kB
Release files / pdfredact-0.0.6.tar.gz
| Download URL | pdfredact-0.0.6.tar.gz |
|---|---|
| Size | 401.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
effb37eeed6162b8952c8574d67a3c5a994c3ebe12b061a36c137b468f9d1742
|
|
BLAKE2b-256 checksum How to use checksums |
c6a4e4301c0d20fe42a3fe397cf2500c28c1520a458c37a9c22789ec71eaed95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Release files / pdfredact-0.0.6-py3-none-any.whl
| Download URL | pdfredact-0.0.6-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8fef08606007ad5e0e49c347be0b815ff4293692fd18974eea88cff904ea1366
|
|
BLAKE2b-256 checksum How to use checksums |
b3e0ce35aaad3e16c1fe721361a85389539bbe4c8408112498f34f7ceea0b023
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Security for pdfredact 0.0.6
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.