Set password for output 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 →

On this page

GroupDocs.Comparison allows you to protect output document with password.

To protect output document, follow these steps:

  1. Instantiate the Comparer object. Specify the source document path or stream.
  2. Call the Add method. Specify the target document path or stream.
  3. Instantiate the CompareOptions object. Set the  PasswordSaveOption to PasswordSaveOption.User.
  4. Instantiate the SaveOptions object. Use the Password property to specify a password string.
  5. Call the Compare method. Specify the SaveOptions and CompareOptions objects as parameters.

The following code snippet shows how to compare documents and protect the output document with password:

using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...

using (Comparer comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");
    CompareOptions cOptions = new CompareOptions
    {
        PasswordSaveOption = PasswordSaveOption.User
    };
    SaveOptions sOptions = new SaveOptions()
    {
        Password = "3333"
    };
    comparer.Compare("result.docx", sOptions, cOptions);
}

See also

On this page