How to save document with password

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.Signature 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-signature -- dnx GroupDocs.Signature.Mcp --yes
Folders, licensing and more →

Signature class supports saving signed document with password protection. This ability is supported over Password property of SaveOptions class that should be passed to Sign method.

Here are the steps to protect signed document with password with GroupDocs.Signature:

  • Create new instance of Signature class and pass source document path or stream as a constructor parameter.
  • Instantiate required signature options.
  • Instantiate the SaveOptions object and specify Password property with required password string.
  • Call Sign method of Signature class instance and pass signatureoptions and SaveOptions object to it.

Following example demonstrates how to save signed document with password.

using (Signature signature = new Signature("sample.pdf"))
{
    // create QRCode option with predefined QRCode text
    QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith")
    {
        // setup QRCode encoding type
        EncodeType = QrCodeTypes.QR,
        // set signature position
        Left = 100,
        Top = 100
    };
    SaveOptions saveOptions = new SaveOptions()
    {
        Password = "1234567890",
        UseOriginalPassword = false
    };
    // sign document to file
    signature.Sign("SignedProtected.pdf", signOptions, saveOptions);
}

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.