Some documents formats (such as PDF, DOC, DOCX, XLS, XLSX, etc), 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 until the correct password is applied to decrypt it. Unusable means that only the information properties of the document are available (such as its DocumentId, DocumentType and MimeType). The Pages collection will be empty and cannot interact with the document by getting any more information from it.
There are two ways to pass the password phrase needed to decrypt a document:
Set 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 repeat the entire process (a non-optimal solution).
Call the DocumentFactory.LoadFromUri with LoadDocumentOptions.Password set to null. A LEADDocument will be returned with the following property values:
If the Document is encrypted, then the value of LEADDocument.IsEncrypted is set to true by the factory. And the value of LEADDocument.IsDecrypted, is intialized to false.
The application can check for this condition 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
Loading Using LEADTOOLS Document Library
Creating Documents with LEADTOOLS Document Library
Uploading Using the Document Library
Document Library Coordinate System
Parsing Text with the Document Library
Barcode processing with the Document Library
Document Toolkit History Tracking
Using LEADTOOLS Document Viewer
Using LEADTOOLS Document Converters
Document View and Convert Redaction
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document