Set password for output document
Leave feedback
On this page
GroupDocs.Comparison allows you to protect output document with password.
To protect output document, follow these steps:
- Instantiate the Comparer object. Specify the source document path or stream.
- Call the add() method. Specify the target document path or stream.
- Instantiate the CompareOptions object. Call the setPasswordSaveOption() method and specify the
PasswordSaveOption.USER
value. - Instantiate the SaveOptions object. Call the setPassword() property to specify a password string.
- 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:
try (Comparer comparer = new Comparer(sourceFile)) {
comparer.add(targetFile);
CompareOptions compareOptions = new CompareOptions();
compareOptions.setPasswordSaveOption(PasswordSaveOption.USER);
SaveOptions saveOptions = new SaveOptions();
saveOptions.setPassword("3333");
final Path resultPath = comparer.compare(outputFile, saveOptions, compareOptions);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.