__init__ constructor

init

Initializes a new Redactor instance using a file path.

def __init__(self, file_path):
    ...
Parameter Type Description
file_path str Path to the file.

Example

from groupdocs.redaction import Redactor

with Redactor("./sample.docx") as redactor:
    # Perform redaction operations here
    pass

init

Initializes a new Redactor instance using a document stream.

def __init__(self, document):
    ...
Parameter Type Description
document io.RawIOBase Source stream of the document.

Example

from groupdocs.redaction import Redactor

with open("./sample.docx", "rb") as stream:
    # Load the document from the stream
    with Redactor(stream) as redactor:
        # Perform redaction operations here
        pass

init

Initializes a new Redactor instance for a password-protected document using its path.

def __init__(self, file_path, load_options):
    ...
Parameter Type Description
file_path str Path to file.
load_options LoadOptions Options, including password.

init

Initializes a new instance of Redactor for a password‑protected document using its path and settings.

def __init__(self, file_path, load_options, settings):
    ...
Parameter Type Description
file_path str Path to file.
load_options LoadOptions File-dependent options, including password.
settings RedactorSettings Default settings for redaction process.

init

Initializes a new Redactor instance for a password‑protected document using a stream.

def __init__(self, document, load_options):
    ...
Parameter Type Description
document io.RawIOBase Source input stream.
load_options LoadOptions Options, including password.

Example

from groupdocs.redaction import Redactor
from groupdocs.redaction.options import LoadOptions

def open_protected():
    load_options = LoadOptions("mypassword")
    with open("./sample.pdf", "rb") as stream:
        with Redactor(stream, load_options) as redactor:
            # Perform redactions here
            pass

init

Initializes a new instance of Redactor for a password‑protected document using a stream and optional settings.

def __init__(self, document, load_options, settings):
    ...
Parameter Type Description
document io.RawIOBase Source input stream.
load_options LoadOptions Options, including password.
settings RedactorSettings Default settings for the redaction process.

See Also