LoadOptions class

LoadOptions class

Provides options that will be used to open a file.

The LoadOptions type exposes the following members:

Constructors

Constructor Description
init Initializes a new instance of LoadOptions class.
init Initializes a new LoadOptions instance with the specified file type.
init Initializes a new LoadOptions instance with the specified password.
init Initializes a new LoadOptions instance with a pre‑rasterization flag.
init Initializes a new LoadOptions instance with an optional password and an optional pre‑rasterization flag.

Properties

Property Description
file_type The type of the file to open.
password The password for password-protected documents.
pre_rasterize The pre-rasterize flag indicating whether the file should be pre-rasterized.

Example

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

def load_password_protected_file():
    # Specify the load options with the document password
    load_opt = LoadOptions("mypassword")

    # Specify the redaction options
    repl_opt = ReplacementOptions("[personal]")
    ex_red = ExactPhraseRedaction("Emily Johnson", repl_opt)

    # Load the password-protected document to be redacted
    with Redactor("./protected.docx", load_opt) as redactor:
        redactor.apply(ex_red)

        # Save the redacted document in its original format
        so = SaveOptions()
        so.add_suffix = True
        so.rasterize_to_pdf = False
        so.redacted_file_suffix = "redacted"
        result_path = redactor.save(so)
        print(f"Document redacted successfully.\nCheck output in {result_path}.")

if __name__ == "__main__":
    load_password_protected_file()

Guides

Task guides that use LoadOptions:

See Also