In This Topic ▼

Loading Encrypted Files Using the Document Library


Some document file types support optional encryption and require being decrypted with a password before they can be used. PDF is an example of such documents.

When you use the LoadFromUri or LoadFromCache methods to load these documents, a Document object is created and returned as usual. It will, however, be encrypted and unusable until the correct password is applied to decrypt it. Unusable means only the information properties of the document are available (such as its DocumentId and MimeType), but the Pages collection will be empty and you cannot interact with the document by getting any more information from it.

There are two ways to pass the password phrase used to decrypt this document:

  • Set the password in the 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 (not in the cache) and is loaded using LoadFromUri then it will be downloaded to the cache or a temporary file before having the password applied. And if the password is wrong, an exception will be thrown and the document is deleted. Retrying with another password requires the application to call LoadFromUri again and repeating the whole process which is not a good solution in this case.

  • Instead of setting the password before the document is added to the cache, leave Password as null. This will return a Document as usual but will have the IsEncrypted value set to true (it is encrypted) and IsDecrypted value set to false (it has not been decrypted).

    The application can check for this value and then prompt the user for the password phrase. It can then call Decrypt with the password as many times as needed while checking the 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 IsEncrypted

See Also

Document Library Features

Document Viewer Application

Loading Documents Using LEADTOOLS Document Library

Creating Documents with LEADTOOLS Document Library

Document Toolkit and Caching

Uploading Using the Document Library

Document Library Coordinate System

Parsing Text with the Document Library

Barcode processing with the Document Library

Using jQuery Promises in the Document Library

Loading Images in the Document Library

Document Page Transformation

Using LEADTOOLS Document Viewer

Status Document Job Converter

Document View and Convert Redaction

Help Version 20.0.2019.12.4
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.