Leadtools.Documents Namespace > DocumentFactory Object : LoadFromCache Method |
function Leadtools.Documents.DocumentFactory.loadFromCache( documentId )
Parameter | Type | Description |
---|---|---|
documentId | string | documentId from a previously cached Document object. |
Type | Description |
---|---|
jQueryApi.IDeferred | A Promise object that may resolve succesfully to a Document object, or fail if the Document cannot be returned because it does not exist with that documentId. |
This static method will return a Document object that is known to already exist in the cache from being loaded via LoadFromUri or uploaded via UploadFile or UploadDocument.
LoadFromCache is meant as a quick version of LoadFromUri and does not take a LoadDocumentOptions object.
If DeleteFromCache is called on the Document or the cache time has expired for the object, it will not be available via this method.
function loadDocumentFromCacheExample() { // Load a new document var url = "http://demo.leadtools.com/images/pdf/leadtools.pdf"; lt.Documents.DocumentFactory.loadFromUri(url, null) .done(function (document) { console.log("Document was loaded succesfully from URI"); console.log("MIMEType is " + document.mimeType); console.log("Number of Pages is " + document.pages.length); // get the ID and get rid of the document var documentId = document.documentId; document = null; // Load it from the cache now lt.Documents.DocumentFactory.loadFromCache(documentId) .done(function (document) { console.log("Document was loaded succesfully from cache"); console.log("MIMEType is " + document.mimeType); console.log("Number of Pages is " + document.pages.length); }) .fail(function (jqXHR, statusText, errorThrown) { alert("Error loading document " + errorThrown); }); }) .fail(function (jqXHR, statusText, errorThrown) { alert("Error loading document " + errorThrown); }); }