RedactorSettings class

RedactorSettings class

Represents redaction settings, allowing to customize the redaction process.

Learn more

The RedactorSettings type exposes the following members:

Constructors

Constructor Description
init Initializes a new instance of the RedactorSettings class.
init Initializes a new RedactorSettings instance with the specified logger.
init Initializes a new RedactorSettings instance with a given IRedactionCallback implementation.
init Initializes a new RedactorSettings instance with the specified IOcrConnector.
init Initializes a new instance of the RedactorSettings class with given ILogger and IRedactionCallback instances.
init Initializes a new RedactorSettings instance with optional logger, callback, and OCR connector.

Properties

Property Description
logger The logger used for logging events and errors. It must implement ILogger.
ocr_connector The OCR connector used to recognize text in images, which must implement IOcrConnector.
redaction_callback The redaction callback that implements IRedactionCallback and is invoked for each redaction.

Example

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

class RedactionDump:
    def accept_redaction(self, description):
        print(f"{description.redaction_type.name} redaction, {description.action_type.name} action, item {description.original_text}.")
        if description.replacement is not None:
            print(f"Text {description.replacement.original_text} is replaced with {description.replacement.replacement}.")
        return True

settings = RedactorSettings(RedactionDump())
with Redactor("./sample.docx", LoadOptions(), settings) as redactor:
    redactor.apply(ExactPhraseRedaction("Emily Johnson", ReplacementOptions("[personal]")))
    result_path = redactor.save()
    print("Document redacted. Output saved to", result_path)

Guides

Task guides that use RedactorSettings:

See Also