The Documents library supports loading by creating a Document object from data that reside in a disk file or a remote URL or data that was previously uploaded to the cache system.
This topic discusses the loading the information associated with representing a document as a Document object. For a discussion of loading individual page images or thumbnails for a DocumentPage, see Image Loading.
Loading from remote URL
To load a Document object from a remote URL call LoadFromUri, passing the URL pointing to the remote location of the document file and an instance (which can be null) of LoadDocumentOptions. Refer to LoadFromUri for an example.
Following is an explanation on how this method works.
If the uri passed to LoadFromUri has the special LEAD cache scheme (detected using IsUploadDocumentUri), then the factory assumes this is the URI to a document previously uploaded to the cache using LoadFromUri and steps below are not performed and no data is downloaded. The data is already in the cache and the factory skips to step 4 below.
If the value of AnnotationsUri is not null, then it will be treated as a remote URL and the data is downloaded by the factory in the same manner used for the document file as explained below.
The factory will downloaded the document dta from uri into the cache system.
Similarly, if AnnotationsUri is not null, it will be downloaded to the cache system.
The factory will obtain information on the file format on the downloaded or temporary file. If this fails (invalid file format or the required LEADTOOLS file format assembly is not found), then the cache data is deleted and an exception is thrown.
A Document object is created and the following members are initialized:
Member | Value |
---|---|
DocumentId |
A unique identifier created for this document that can be used if the document is saved to the cache. |
Uri |
Same uri passed to LoadFromUri. |
IsReadOnly | true. |
CacheUri | If the document was downloaded to the cache and if the cache system has virtual directory capabilities, then this property will contain a URI to the original document data (PDF, TIFF, DOCX, etc.). Otherwise, is null. |
MimeType |
The MIME type of the document file format set during load. |
LastCacheSyncTime | Random old date since the document has not been saved to the cache yet. |
CacheStatus | DocumentCacheStatus.NotSynced since the document has not been saved to the cache yet. |
IsEncrypted |
false unless the document is encrypted. In this case most of the document properties cannot be used before the document is decrypted. Refer to Loading Encrypted Files Using the Documents Library for more information. |
IsDecrypted |
false |
IsStructureSupported |
true or false based on the MIME type of the document. |
Metadata |
Ready to be used. |
Structure |
Ready to be used. |
Images |
Ready to be used. |
Text |
Ready to be used. |
Pages |
Ready to be used. |
Documents | Empty collection since this is not a virtual document. |
HasDocuments | false. |
AutoDisposeDocuments | false. |
Annotations |
Ready to be used. |
LoadFromUri returns with this Document object ready to be used.
Document will parse data from the downloaded data, therefore the original URL is never used again and the data it points to can be deleted right away if necessary.
Refer to LoadFromUri for an example.
As stated above, a valid uri to a Document in the cache scheme can be retrieved from LoadFromUri without issue. However, LoadFromCache also exists as a subset of LoadFromUri's functionality for instances in which a Document has already been loaded once but must be loaded again. LoadFromCache does not take a LoadDocumentOptions object.
LoadFromCache uses the DocumentId property to download the Document data, so that value may be stored instead of the Uri when holding on to cache items for later.
Refer to LoadFromUri for an example.
Creating Documents with LEADTOOLS Documents Library
Uploading Using the Documents Library
Documents Library Coordinate System
Loading Encrypted Files Using the Documents Library
Parsing Text with the Documents Library
Barcode processing with the Documents Library
Using jQuery Promises in the Documents Library