Some documents formats such as PDF, support optional encryption and require being decrypted with a password before they can be used.
When using the DocumentFactory to load such documents, a LEADDocument object is created and returned as usual. However it will be encrypted and unusable till the correct password is applied to decrypt it. Unusable means only the information properties of the document are available (such as its DocumentId, DocumentType and MimeType), but the Pages collection will be empty and cannot interact with the document by getting any more information from it.
Two ways to pass the password phrase used to decrypt a document:
Setting the password in the LoadDocumentOptions.Password property. This is the easiest way but requires the correct password to be available before the document is loaded. If the document is in a remote location and is loaded using DocumentFactory.LoadFromUri, then it will be downloaded to the cache or a temporary file before having the password applied.
If the password is wrong, an exception will be thrown and the document will be deleted.
Retrying with another password requires the application to call DocumentFactory.LoadFromUri again and repeating the whole process which is non-optimal solution.
The application can check for this value and then prompt the user for the password phrase, it can then call LEADDocument.Decrypt with the password as many times as needed while checking the LEADDocument.IsDecrypted property. When this property becomes true, it means the correct password was applied and the document is unlocked and ready to use.
For an example, refer to LEADDocument.IsEncrypted
Medical Web Viewer .NET