Load from local disc

On this page

GroupDocs.Redaction.Redactor class is a main class in Redaction API, providing functionality to open a document. When document is located on the local disk, you can pass its path to Redactor class constructor.

The following example demonstrates how to open a document from local disc:

from groupdocs.redaction import Redactor
from groupdocs.redaction.options import SaveOptions
from groupdocs.redaction.redactions import DeleteAnnotationRedaction


def load_from_local_disc():
    # Specify the redaction options - remove all annotations
    del_red = DeleteAnnotationRedaction()

    # Load the document to be redacted from the local disc
    with Redactor("./sample.docx") as redactor:

        # Apply the redaction
        redactor.apply(del_red)

        # Save the redacted document in its original format next to the source file
        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_from_local_disc()

sample.docx is the sample file used in this example. Click here to download it.

Binary file (DOCX, 13 KB)

Download full output

On this page