accept_redaction method

accept_redaction

Triggered right before applying any redaction to the document, allowing logging or forbidding it.

def accept_redaction(self, description):
    ...
Parameter Type Description
description RedactionDescription Contains information about the particular match type, criteria, text and position.

Returns: bool: True to accept the redaction, False to decline it.

Example

from groupdocs.redaction import Redactor
from groupdocs.redaction.options import LoadOptions, RedactorSettings
from groupdocs.redaction.redactions import ExactPhraseRedaction, ReplacementOptions

class RedactionLogger:
    def accept_redaction(self, description):
        print(f"{description.redaction_type.name} redaction, original text: {description.original_text}")
        return True

settings = RedactorSettings(RedactionLogger())
with Redactor("sample.docx", LoadOptions(), settings) as redactor:
    redactor.apply(ExactPhraseRedaction("Emily Johnson", ReplacementOptions("[personal]")))
    redactor.save()

Aliases

These names call accept_redaction too, limited to the overloads listed.

Alias Accepts
accept_redaction_redaction_description accept_redaction_redaction_description(description)

See Also