Set a Password for the Resultant Document

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison for Python via .NET can apply a password to the comparison result. Combine CompareOptions.password_save_option = PasswordSaveOption.USER with SaveOptions.password = "<your password>".

Example: Password-protect the result document

from groupdocs.comparison import Comparer
from groupdocs.comparison.options import CompareOptions, SaveOptions, PasswordSaveOption

def set_password_for_resultant_document():
    with Comparer("./source.docx") as comparer:
        comparer.add("./target.docx")

        compare_options = CompareOptions()
        compare_options.password_save_option = PasswordSaveOption.USER

        save_options = SaveOptions()
        save_options.password = "3333"

        comparer.compare("./result.docx", save_options, compare_options)

if __name__ == "__main__":
    set_password_for_resultant_document()

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

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

Binary file (DOCX, 25 KB)

Download full output

Opening result.docx will require the password 3333.