Working with Password Protected Documents
Some document formats also support protection using a password to prevent others from changing or even opening the document. GroupDocs.Viewer also supports rendering of such documents.
The following are the steps to render password protected documents.
- Instantiate the HtmlOptions or ImageOptions object
- Set password using setPassword(String) method
- Get pages
The following code sample shows how to render password protected documents.
Forced Password Validation
When password protected documents are rendered with the caching enabled, the document password is validated only on the first call. All subsequent renderings will provide output without checking the document password. In order to alter this behavior and let the API to validate document password on each rendering, use setForcePasswordValidation(true) method of the ViewerConfig object as shown in the code sample below.