RedactionPolicy class

RedactionPolicy class

Represents a sanitization policy, containing a set of specific redactions to apply.

Learn more

The RedactionPolicy type exposes the following members:

Constructors

Constructor Description
init Initializes a new RedactionPolicy instance.
init Initializes a new RedactionPolicy with a specific list of redactions.

Methods

Method Description
load Loads a RedactionPolicy from an XML file.
load Loads a RedactionPolicy instance from a stream containing XML configuration.
load_file
load_stream
load_streams
load_string
save Saves the redaction policy to a file.
save Saves the redaction policy to a stream.
save_file
save_stream
save_streams
save_string

Properties

Property Description
redactions The list of fully configured Redaction-derived classes.

Example

from groupdocs.redaction import Redactor, RedactionPolicy
from groupdocs.redaction.redactions import ExactPhraseRedaction, RegexRedaction, ReplacementOptions

# Build a reusable policy in memory
policy = RedactionPolicy([
    ExactPhraseRedaction("ACME", ReplacementOptions("[CO]")),
    RegexRedaction(r"\d{2,}", ReplacementOptions("[NUM]")),
])

# Apply the policy to a document
with Redactor("document.docx") as redactor:
    redactor.apply(policy=policy)
    redactor.save()

Guides

Task guides that use RedactionPolicy:

See Also