Document Object Loading - Namespace - HTML5 JavaScript Help

Document Object Loading

Summary

The Documents library supports loading by creating a Document object from data that resides 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.

  1. 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.

  2. 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.

  3. The factory will downloaded the document dta from uri into the cache system.

  4. Similarly, if AnnotationsUri is not null, it will be downloaded to the cache system.

  5. 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.

  6. 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.

  7. LoadFromUri returns with this Document object ready to be used.

  8. 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.

Loading from Cache

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.

Help Version 20.0.2018.7.3
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS HTML5 JavaScript