__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 instance of Redactor using a stream.

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

Example

from groupdocs.redaction import Redactor

def open_from_stream():
    # Open the document as a binary stream
    with open("./sample.pdf", "rb") as stream:
        # Load the document from the stream
        with Redactor(stream) as redactor:
            # Perform redactions here
            pass

init

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

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

Example

from groupdocs.redaction import Redactor

# Load a password‑protected document from a file path
with Redactor("protected.docx") as redactor:
    # Perform redaction operations here
    pass

init

Initializes a new Redactor instance 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.

Example

from groupdocs.redaction import Redactor

with Redactor("./sample.docx") as redactor:
    info = redactor.get_document_info()
    print(f"File type: {info.file_type}")
    print(f"Number of pages: {info.page_count}")
    print(f"Document size: {info.size} bytes")

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, LoadOptions

def open_protected_doc():
    # Open the protected PDF as a binary stream
    with open(r"C:\sample.pdf", "rb") as stream:
        # Provide the password via LoadOptions
        load_options = LoadOptions("mypassword")
        # Initialize Redactor with the stream and load options
        with Redactor(stream, load_options) as redactor:
            # Perform redaction operations here
            pass

init

Initializes a new instance of Redactor for a password‑protected document using a stream and 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