GroupDocs.Redaction for Python via .NET is an API library that helps you erase sensitive and classified data from various file formats, such as, Microsoft Word, Excel, PowerPoint and PDF. Our Redaction API’s single format-independent interface supports redaction of various types, e.g., text redaction, metadata redaction, annotation redaction, and tabular document redaction. GroupDocs.Redaction for Python via .NET API also allows you to redact password protected files. You are allowed to save the document in its original format as well as create a sanitized PDF document with raster images of original pages.
GroupDocs.Redaction for Python via .NET API grants you complete control over how you want to hide or erase your important classified information from supported document. To use our Redaction API is pretty simple and straight forward.
In following example, we load a supported document, redact out any text, matching “2 digits, space or nothing, 2 digits, again space and 6 digits” (such as 12 34 567890) with a blue color box using Python. Once that is done, it saves the document in its original format by renaming it with an added suffix “_Redacted”:
import groupdocs.redaction as gr
import groupdocs.redaction.redactions as grr
import groupdocs.pydrawing as grd
def run():
# Specify the redaction options
color = grd.Color.from_argb(255, 220, 20, 60)
repl_opt = grr.ReplacementOptions(color)
reg_red = grr.RegexRedaction("\\d{2}\\s*\\d{2}[^\\d]*\\d{6}", repl_opt)
# Load the document to be redacted
with gr.Redactor("source.pdf") as redactor:
# Apply the redaction
result = redactor.apply(reg_red)
# Save the redacted document
result_path = redactor.save()