accept_redaction method

accept_redaction

Triggers 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 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.redactions import ExactPhraseRedaction, ReplacementOptions
from groupdocs.redaction.options import LoadOptions, RedactorSettings

def accept(description):
    # description.original_text, .redaction_type, .action_type
    return "keep-me" not in (description.original_text or "")

with Redactor("document.docx", LoadOptions(), RedactorSettings(callback=accept)) as redactor:
    redactor.apply(ExactPhraseRedaction("secret", ReplacementOptions("[X]")))
    redactor.save()

See Also