SaveOptions class

SaveOptions class

Provides options for changing an output file name and/or converting the document to image‑based PDF (rasterization).

Learn more:

The SaveOptions type exposes the following members:

Constructors

Constructor Description
init Initializes a new instance with default settings: rasterize_to_pdf is False and add_suffix is False.
init Initializes a new instance with given parameters.

Properties

Property Description
add_suffix The add_suffix property indicates whether the file name should be changed before saving. Defaults to False.
rasterization The rasterization settings.
rasterize_to_pdf The flag indicating whether all pages in the document are converted to images and combined into a single PDF file.
redacted_file_suffix The custom suffix for the output file name. If not specified, the SaveOptions.SaveSuffix constant is used.

Fields

Field Description
SAVE_SUFFIX Represents default suffix value, which is “Redacted”.

Example

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

def save_with_default_options():
    repl_opt = ReplacementOptions("[personal]")
    ex_red = ExactPhraseRedaction("John Doe", repl_opt)

    with Redactor("./sample.docx") as redactor:
        redactor.apply(ex_red)

        # Save the document with default options (rasterize to PDF and add suffix)
        save_options = SaveOptions()
        save_options.add_suffix = True
        save_options.rasterize_to_pdf = True
        save_options.redacted_file_suffix = "redacted"

        result_path = redactor.save(save_options)
        print(f"Document redacted successfully. Check output in {result_path}.")

Guides

Task guides that use SaveOptions:

See Also