Product Page | Docs | Demos | API Reference | Blog | Free Support | Temporary License
GroupDocs.Redaction for Python via .NET is a document-sanitization API for permanently removing sensitive information. Redact text by exact phrase or regular expression, scrub or replace metadata, remove or rewrite annotations, black out image regions, delete whole pages, find text in scanned images with the OCR engine of your choice, and rasterize the result so nothing redacted can be recovered -- across 40+ Word, Excel, PowerPoint, PDF, image and text formats through one unified API, with no MS Office, OpenOffice, or other external software required.
Get Started
pip install groupdocs-redaction-net
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions
with Redactor("document.docx") as redactor:
redactor.apply(ExactPhraseRedaction("confidential", ReplacementOptions("[REDACTED]")))
redactor.save()
How It Works
The package is a self-contained Python wheel that bundles the .NET 10 runtime and every native dependency (SkiaSharp, Aspose.Drawing) needed to load, redact, and save documents. No external software installation is required -- just pip install and start redacting; pip also installs groupdocs-shared-net, the small package of modules every GroupDocs Python package shares. The wheels work across Python 3.5 - 3.14 on Windows x64, Linux x64, and macOS (Intel + Apple Silicon), with the same features on each: rasterizing to PDF and image-area redaction need neither System.Drawing nor libgdiplus.
Features
- Text redaction -- remove or replace text by exact phrase (case-sensitive or not) or by regular expression; draw a colored box over the match instead of replacing it.
- Metadata redaction -- erase or rewrite document metadata by filter (author, company, comments, ...) or by key/value pattern.
- Annotation redaction -- replace annotation text by pattern or delete matching annotations entirely.
- Image-area redaction -- black out a rectangular region of a page; combine text + image redaction for page areas, scoped to page ranges.
- Page redaction -- remove pages from the start or end of a document.
- Rasterization -- flatten the output to a PDF (optionally with tilt / noise / border / grayscale) so redacted content cannot be extracted.
- OCR connectors -- plug in an OCR engine (Tesseract, a cloud service, ...) as a Python object to redact text in scans and embedded images.
- Callbacks & logging -- approve or reject each change with a Python function, and collect the engine's errors, warnings and traces with a logger object.
- Page previews -- render pages to PNG, JPEG or BMP, to files or to memory.
- Document introspection -- read format, page count, size, and per-page dimensions before processing.
- Format control -- open a stream as a given file type, and save Word documents with a chosen OOXML compliance level.
- Cross-Platform -- Windows x64, Linux x64, macOS x64/ARM64.
Common Tasks
- Strip personal data (names, SSNs, emails, phone numbers) from a contract before sharing
- Black out an exact phrase or a regex match across every page of a document
- Erase all metadata (or just author/company) from a DOCX, XLSX, or PDF
- Remove or rewrite annotations/comments left in a reviewed document
- Redact a fixed image region (a logo, a signature, a photo) on a page
- Rasterize a redacted document to PDF so nothing can be copied back out
Supported File Formats
For a complete list, with the operations each format supports, see supported formats.
| Category | Formats |
|---|---|
| Word Processing | DOC, DOCX, DOCM, DOT, DOTX, DOTM, RTF, ODT, OTT |
| Spreadsheets | XLS, XLSX, XLSM, XLSB, XLT, XLTX, XLTM, ODS, OTS, CSV, TAB |
| Presentations | PPT, PPTX, PPTM, PPS, PPSX, PPSM, POTX, POTM, ODP, OTP |
| Fixed-Layout | PDF, DJVU |
| Images | BMP, JPEG, PNG, GIF, TIFF, WEBP |
| Web & Text | HTML, MD, TXT |
Examples
Redact an exact phrase
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions
with Redactor("document.docx") as redactor:
# case-insensitive by default; pass True for case-sensitive
redactor.apply(ExactPhraseRedaction("Emily Johnson", True, ReplacementOptions("[CUSTOMER]")))
redactor.save()
Redact by regular expression
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import RegexRedaction, ReplacementOptions
with Redactor("document.docx") as redactor:
# numbers (e.g. SSNs, IDs)
redactor.apply(RegexRedaction(r"\d{2,}", ReplacementOptions("[NUMBER]")))
# email addresses
redactor.apply(RegexRedaction(r"[\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}", ReplacementOptions("[EMAIL]")))
redactor.save()
Draw a black box instead of replacing text
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions
from groupdocs.redaction.options.drawing import Color
with Redactor("document.pdf") as redactor:
redactor.apply(ExactPhraseRedaction("Top Secret", ReplacementOptions(Color.black)))
redactor.save()
Scrub metadata
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import EraseMetadataRedaction, MetadataSearchRedaction, MetadataFilters
with Redactor("document.docx") as redactor:
redactor.apply(EraseMetadataRedaction(MetadataFilters.ALL)) # wipe everything
redactor.apply(MetadataSearchRedaction(".*@acme\\.com", "[EMAIL]")) # rewrite by value pattern
redactor.save()
Office, OpenDocument and RTF files lose the properties the filter names. On engine 26.10 a PDF saved as PDF keeps the properties that only its document information dictionary holds, and images other than JPEG keep their EXIF data, although the redaction reports APPLIED: rasterize PDFs (the default of save()) and check image output.
Black out an image region
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import ImageAreaRedaction, RegionReplacementOptions
from groupdocs.redaction.options.drawing import Point, Size, Color
with Redactor("scan.pdf") as redactor:
redactor.apply(ImageAreaRedaction(Point(50, 60), RegionReplacementOptions(Color.black, Size(200, 80))))
redactor.save()
Save in the original format (no rasterization)
By default save() rasterizes the result to a PDF and appends a _Redacted suffix. To keep the source format instead:
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import RegexRedaction, ReplacementOptions
from groupdocs.redaction.options import SaveOptions
with Redactor("document.docx") as redactor:
redactor.apply(RegexRedaction(r"\d+", ReplacementOptions("[NUM]")))
redactor.save(SaveOptions(rasterize_to_pdf=False, add_suffix=True)) # writes document_Redacted.docx
Get document info
from groupdocs.redaction import Redactor
with Redactor("document.pdf") as redactor:
info = redactor.get_document_info()
print("Type:", info.file_type.file_format)
print("Pages:", info.page_count)
print("Size:", info.size, "bytes")
Redact from / to binary streams
import io
from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions
from groupdocs.redaction.options import SaveOptions
with open("document.docx", "rb") as src:
with Redactor(src) as redactor:
redactor.apply(ExactPhraseRedaction("secret", ReplacementOptions("[X]")))
buffer = io.BytesIO()
redactor.save(buffer, SaveOptions(rasterize_to_pdf=False)) # keep the original format
data = buffer.getvalue()
Approve or reject each change
from groupdocs.redaction import Redactor
from groupdocs.redaction.options import LoadOptions, RedactorSettings
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions
def accept(description):
print(description.redaction_type.name, description.original_text)
return "keep" not in (description.original_text or "") # False skips this match
with Redactor("document.docx", LoadOptions(), RedactorSettings(callback=accept)) as redactor:
redactor.apply(ExactPhraseRedaction("Emily Johnson", ReplacementOptions("[CUSTOMER]")))
redactor.save()
Render page previews
import io
from groupdocs.redaction import Redactor
from groupdocs.redaction.options import PreviewOptions, PreviewFormats
pages = {}
def create_page_stream(page_number):
pages[page_number] = io.BytesIO()
return pages[page_number]
with Redactor("document.docx") as redactor:
options = PreviewOptions(create_page_stream)
options.width, options.height = 480, 640 # both required
options.page_numbers = [1] # required
options.preview_format = PreviewFormats.PNG
redactor.generate_preview(options)
print(len(pages[1].getvalue()), "bytes of PNG")
Use your own OCR engine
GroupDocs.Redaction ships no OCR engine; an object with recognize(image_stream) reports the lines an OCR engine found and where. Report each line as one TextFragment: on engine 26.10 a phrase that spans two fragments is reported APPLIED but not painted. The OCR guide builds one on Tesseract.
from groupdocs.redaction import Redactor
from groupdocs.redaction.integration.ocr import RecognizedImage, TextFragment, TextLine
from groupdocs.redaction.options import LoadOptions, RedactorSettings
from groupdocs.redaction.options.drawing import Color, Rectangle
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions
class MyOcr(object):
def recognize(self, image_stream):
image_bytes = image_stream.read() # pass these to your OCR engine
line = TextFragment("Emily Johnson", Rectangle(40, 40, 230, 40)) # one fragment per line
return RecognizedImage([TextLine([line])])
with Redactor("scan.png", LoadOptions(), RedactorSettings(ocr_connector=MyOcr())) as redactor:
print(redactor.apply(ExactPhraseRedaction("Emily Johnson", ReplacementOptions(Color.black))).status.name)
AI Agent & LLM Friendly
This package is designed for seamless integration with AI agents, LLMs, and automated code generation tools.
AGENTS.mdin the package -- AI coding assistants (Claude Code, Cursor, GitHub Copilot) auto-discover the API surface, usage patterns, and troubleshooting tips from the installed package- MCP server -- connect your AI tool to GroupDocs documentation for on-demand API lookups:
{ "mcpServers": { "groupdocs-docs": { "url": "https://docs.groupdocs.com/mcp" } } }
- GroupDocs.Redaction MCP server -- let an agent redact documents locally, with nothing uploaded: docs.groupdocs.com/redaction/mcp
- Machine-readable docs -- full documentation available as plain text for RAG and LLM context:
- Single file:
https://docs.groupdocs.com/redaction/python-net/llms-full.txt - Per page: append
.mdto any docs URL
- Single file:
Evaluation Mode
The API works without a license in evaluation mode, with these limitations:
- Up to 25 documents may be opened per process; the next open raises
TrialLimitationsException. - Saved documents carry a red evaluation notice at the top of each page.
- Long documents are cut short. A rasterized PDF keeps its first 4 pages, and a 10-page Word document saved in its own format kept 152 of its 276 paragraphs. On a PDF of more than 4 pages,
get_document_info()raisesAt most 4 elements (for any collection) can be viewed in evaluation mode, and page and metadata redactions reportFAILEDorSKIPPED.
The number of redactions and replacements is not limited. To remove these limitations, apply a license or request a temporary license:
from groupdocs.redaction import License
License().set_license("path/to/license.lic")
print(License().is_licensed)
Or set the environment variable, a file path or a URL, applied at the first call into the engine:
export GROUPDOCS_LIC_PATH="path/to/license.lic"
A licence from GROUPDOCS_LIC_PATH that cannot be applied raises LicenseError (from groupdocs.redaction) instead of running in evaluation mode silently; GROUPDOCS_LIC_STRICT=0 turns that into a LicenseWarning.
Troubleshooting
| Issue | Platform | Fix |
|---|---|---|
Trial mode allows opening up to 25 documents per process |
All | Apply a license -- License().set_license(...) or set GROUPDOCS_LIC_PATH |
At most 4 elements (for any collection) can be viewed in evaluation mode |
All | Evaluation mode on a PDF of more than 4 pages, which also cuts long documents short: apply a license |
LicenseError on the first call |
All | The licence GROUPDOCS_LIC_PATH names cannot be applied; the message says why |
TypeError: ... no overload matched with a Color, Point or Size |
All | Import them from groupdocs.redaction.options.drawing, not groupdocs.pydrawing |
Process exits with code 134, Couldn't find a valid ICU package |
Linux | apt-get install libicu-dev. Do NOT set DOTNET_SYSTEM_GLOBALIZATION_INVARIANT |
A presentation (PPTX, PPT, ODP, ...) fails to open with DllNotFoundException |
Linux | apt-get install libfontconfig1: the presentation engine links fontconfig |
| Garbled text / missing fonts in output | Linux | apt-get install ttf-mscorefonts-installer fontconfig && fc-cache -f |
An Aspose/Drawing/SystemFontCache.xml appears in the working directory |
Linux | The engine's font cache goes there only when ~/.local/share cannot be created, as in a read-only home: the package creates the folder otherwise. Set XDG_DATA_HOME to a writable folder |
IncorrectPasswordException / PasswordRequiredException |
All | Open with Redactor(path, LoadOptions(password="...")) |
System Requirements
- Python 3.5 - 3.14, with pip 20.3 or later
- Windows x64; Linux x64 with glibc 2.27+ (ICU, fontconfig and fonts installed); macOS 12+ on Intel or Apple Silicon
- No
libgdiplus, MS Office or other software needed
Upgrading from 26.6
- Colors and geometry moved.
Color,Point,Size(and the newRectangle,Font,FontStyle) come fromgroupdocs.redaction.options.drawing, as the .NET API'sGroupDocs.Redaction.Options.Drawing.groupdocs.pydrawingtypes are refused with aTypeError, andfrom groupdocs.redaction import Colorno longer works. - Redaction callbacks get the engine's
RedactionDescription:redaction_typeandaction_typeare enums (RedactionType.TEXT), no longer names, andreplacementanddetailsare new. - Linux and macOS rasterize to PDF and redact image areas; 26.6 raised
PlatformNotSupportedExceptionthere. - Evaluation mode allows 25 documents per process and no longer limits redactions or replacements; 26.6 allowed one document, one redaction and four replacements. Long documents are still cut short (see Evaluation Mode).
More Resources
Also available for other platforms: .NET | Java | Node.js
Product Page | Docs | Demos | API Reference | Blog | Free Support | Temporary License
Metadata
Release files for groupdocs-redaction-net 26.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| groupdocs_redaction_net-26.11.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for groupdocs_redaction_net-26.11.0-py3-none-win_amd64.whl |
| groupdocs_redaction_net-26.11.0-py3-none-manylinux_2_27_x86_64.whl | Python 3 | none | Linux glibc 2.27+ x86-64 | Details for groupdocs_redaction_net-26.11.0-py3-none-manylinux_2_27_x86_64.whl |
| groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details for groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_x86_64.whl |
| groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details for groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_arm64.whl |
Total release size: 613.7 MB
Release files / groupdocs_redaction_net-26.11.0-py3-none-win_amd64.whl
| Download URL | groupdocs_redaction_net-26.11.0-py3-none-win_amd64.whl |
|---|---|
| Size | 152.4 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c7323a72821ab3128e7eef4c7a1d785d0a6598fcc4b2bee61fd5d4e1facac13d
|
|
BLAKE2b-256 checksum How to use checksums |
94e6d1a9ea5535f6ee1aaed740762973b1834e0ffb4b522e9a2ac8339e06e66b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / groupdocs_redaction_net-26.11.0-py3-none-manylinux_2_27_x86_64.whl
| Download URL | groupdocs_redaction_net-26.11.0-py3-none-manylinux_2_27_x86_64.whl |
|---|---|
| Size | 153.1 MB |
| Tags | Linux glibc 2.27+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
6b499b30044cf788e1033d698f6325cb171b5c8e537719ffd5ff48cd21e2eaa2
|
|
BLAKE2b-256 checksum How to use checksums |
8fc8606fbd976c3207424509abde9340ebcbdabbdf4ecb811614130e303fe574
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_x86_64.whl
| Download URL | groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_x86_64.whl |
|---|---|
| Size | 155.3 MB |
| Tags | Python 3 macOS 12.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
8587f8609ffc5e799ab7d5b9e9f69e2aad4a7eba155be751ac064287cac01710
|
|
BLAKE2b-256 checksum How to use checksums |
bb4ead4578a2e8ff83fe9ac06a728f0bae6d83049a0441d88c1020df9f02a07f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_arm64.whl
| Download URL | groupdocs_redaction_net-26.11.0-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 152.9 MB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f2bf3037da161e5ad70f5ab161c5bfa602879077074ce1a897e3fde547519c03
|
|
BLAKE2b-256 checksum How to use checksums |
c93f997617feea6637c9c49829d8222a736a324b419c8e74b4b9d9b358690750
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Security for groupdocs-redaction-net 26.11.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.
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.