checkCacheInfo Method

Summary

Retrieves information for a document in the cache using its ID.

Syntax
TypeScript
JavaScript
checkCacheInfo = function( 
   uri 
) 
static checkCacheInfo( 
   uri: string 
): JQueryPromise<CacheInfo>; 

Parameters

uri

The document's URI. This value cannot be null. This can be the URL to a document previously uploaded to the cache or a document ID.

Return Value

A Promise object that may resolve successfully to a CacheInfo object, or null if a document with such URL or document ID does not exist.

Remarks

Use checkCacheInfo to quickly obtain information on a document in the cache without loading it. This includes whether the document is in the cache, its name and mime type, the number of pages and whether it was loaded by the user.

Example

This example shows how to use checkCacheInfo to get information on a document in the cache.

Start with the example from LEADDocument and replace all the code inside the example function (search for the "// TODO: add example code here" comment) with the following code:

TypeScript
JavaScript
// Load a new document 
var url = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
var loadDocumentOptions = new lt.Document.LoadDocumentOptions(); 
lt.Document.DocumentFactory.loadFromUri(url, loadDocumentOptions) 
   .done(function (doc) { 
      log("Document loaded with " + doc.pages.count + " pages", doc); 
      // Check its cache info 
      lt.Document.DocumentFactory.checkCacheInfo(doc.documentId) 
         .done(function (cacheInfo) { 
            if (cacheInfo) { 
               // Found, show it 
               log("Document was found in the cache"); 
               log("IsVirtual is " + cacheInfo.isVirtual); 
               log("IsLoaded is " + cacheInfo.isLoaded); 
               log("HasAnnotations is " + cacheInfo.hasAnnotations); 
               log("Name is " + cacheInfo.name); 
               log("MIMEType is " + cacheInfo.mimeType); 
               log("MIMEType accepted " + cacheInfo.isMimeTypeAccepted); 
               log("Number of Pages is " + cacheInfo.pageCount); 
            } else { 
               log("Document was not found in the cache"); 
            } 
         }) 
         .fail(showServiceError); 
   }) 
   .fail(showServiceError); 
class DocumentFactory_CheckCacheInfoExample { 
    public constructor() { 
        lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/v200/LEADTOOLSEVAL.txt", "EVAL", null); 
    } 
 
    public run(buttonID: string) { 
        document.getElementById(buttonID).onclick = this.checkCache; 
    } 
 
    checkCache = () => { 
        // Load a new document 
        const url = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
        const loadDocumentOptions = new lt.Document.LoadDocumentOptions(); 
 
        lt.Document.DocumentFactory.loadFromUri(url, loadDocumentOptions) 
            .done((document: lt.Document.LEADDocument) => { 
                log("Document loaded with " + document.pages.count + " pages", document); 
                // Check its cache info 
                lt.Document.DocumentFactory.checkCacheInfo(document.documentId) 
                .done((cacheInfo) => { 
                    if (cacheInfo) { 
                        // Found, show it 
                        log("Document was found in the cache"); 
                        log("IsVirtual is " + cacheInfo.isVirtual); 
                        log("IsLoaded is " + cacheInfo.isLoaded); 
                        log("HasAnnotations is " + cacheInfo.hasAnnotations); 
                        log("Name is " + cacheInfo.name); 
                        log("MIMEType is " + cacheInfo.mimeType); 
                        log("MIMEType accepted " + cacheInfo.isMimeTypeAccepted); 
                        log("Number of Pages is " + cacheInfo.pageCount); 
                    } else { 
                        log("Document was not found in the cache"); 
                    } 
                }) 
                .fail(showServiceError); 
            }) 
            .fail(showServiceError); 
    } 
} 

Requirements

Target Platforms

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

Leadtools.Document Assembly