Save signed document with password

Signature  class supports saving signed document with password protection. This ability is supported over setPassword 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 setPassword 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.

Signature signature = new Signature("sample.pdf");
// create QRCode option with predefined QRCode text
QrCodeSignOptions signOptions = new QrCodeSignOptions("JohnSmith");
signOptions.setEncodeType(QrCodeTypes.QR);
signOptions.setLeft(100);
signOptions.setTop(100);
 
SaveOptions saveOptions = new SaveOptions();
saveOptions.setPassword("1234567890");
saveOptions.setUseOriginalPassword(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 App 

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.