Retrieves information for a document in the cache using its ID.
public static DocumentCacheInfo GetDocumentCacheInfo(ObjectCache cache,string documentId)
Public Shared Function GetDocumentCacheInfo(ByVal cache As ObjectCache,ByVal documentId As String) As DocumentCacheInfo
public:static DocumentCacheInfo^ GetDocumentCacheInfo(ObjectCache^ cache,String^ documentId)
cache
The cache object to use. This value cannot be null.
documentId
The document identifier. This value cannot be null.
DocumentCacheInfo object that contains the information of the document referenced by documentId such as its name, mime type, page count if the document was found in the cache; otherwise, null if no document with the ID specified by documentId was found in the cache.
Use GetDocumentCacheInfo 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.
This example shows how to use GetDocumentCacheInfo to get information on a document in the cache in various stages.
using Leadtools;using Leadtools.Codecs;using Leadtools.Document.Writer;using Leadtools.Svg;using LeadtoolsExamples.Common;using Leadtools.Document;using Leadtools.Caching;using Leadtools.Annotations.Engine;using Leadtools.Ocr;using Leadtools.Barcode;using Leadtools.Document.Converter;public static void GetDocumentCacheInfoExample(){string documentFile = Path.Combine(ImagesPath.Path, "Leadtools.pdf");// Setup a cacheFileCache cache = new FileCache();cache.CacheDirectory = @"c:\cache-dir";// We will use this document IDconst string documentId = "test-document";// Ensure that the document does not exist in the cachevar deleteFromCacheOptions = new LoadFromCacheOptions();deleteFromCacheOptions.Cache = cache;deleteFromCacheOptions.DocumentId = documentId;DocumentFactory.DeleteFromCache(deleteFromCacheOptions);DocumentCacheInfo cacheInfo;// Now get the info for this document, it should not existcacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId);Debug.Assert(cacheInfo == null);// Next, upload a document into this cachevar uploadDocumentOptions = new UploadDocumentOptions();uploadDocumentOptions.Cache = cache;uploadDocumentOptions.DocumentId = documentId;uploadDocumentOptions.Name = "Leadtools.pdf";Uri uploadUri = DocumentFactory.BeginUpload(uploadDocumentOptions);using (var stream = File.OpenRead(documentFile)){var buffer = new byte[stream.Length];stream.Read(buffer, 0, buffer.Length);DocumentFactory.UploadDocument(cache, uploadUri, buffer, 0, buffer.Length);}DocumentFactory.EndUpload(cache, uploadUri);// Now check the info again, it should be there but not loadedcacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId);Console.WriteLine("After upload");Console.WriteLine(" DocumentId:" + cacheInfo.DocumentId);Console.WriteLine(" Name:" + cacheInfo.Name);Console.WriteLine(" IsLoaded:" + cacheInfo.IsLoaded);Debug.Assert(cacheInfo.DocumentId == documentId);Debug.Assert(cacheInfo.Name == "Leadtools.pdf");Debug.Assert(!cacheInfo.IsLoaded);// Next load this documentvar loadDocumentOptions = new LoadDocumentOptions();loadDocumentOptions.Cache = cache;using (var document = DocumentFactory.LoadFromUri(uploadUri, loadDocumentOptions)){// Save it to the cachedocument.AutoSaveToCache = false;document.AutoDeleteFromCache = false;document.SaveToCache();}// Now get its info again, it should be there and loadedcacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId);Console.WriteLine("After load");Console.WriteLine(" DocumentId:" + cacheInfo.DocumentId);Console.WriteLine(" Name:" + cacheInfo.Name);Console.WriteLine(" IsLoaded:" + cacheInfo.IsLoaded);Debug.Assert(cacheInfo.DocumentId == documentId);Debug.Assert(cacheInfo.Name == "Leadtools.pdf");Debug.Assert(cacheInfo.IsLoaded);}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Document.WriterImports Leadtools.SvgImports Leadtools.DocumentImports Leadtools.CachingImports Leadtools.Annotations.EngineImports Leadtools.BarcodeImports Leadtools.OcrImports LeadtoolsDocumentExamples.LeadtoolsExamples.CommonImports Leadtools.Document.ConverterPublic Shared Sub GetDocumentCacheInfoExample()Dim documentFile As String = Path.Combine(ImagesPath.Path, "Leadtools.pdf")' Setup a cacheDim Cache As New FileCache()Cache.CacheDirectory = "c:\cache-dir"' We will use this document IDConst documentId As String = "test-document"' Ensure that the document does Not exist in the cacheDim deleteFromCacheOptions As New LoadFromCacheOptionsdeleteFromCacheOptions.Cache = CachedeleteFromCacheOptions.DocumentId = documentIdDocumentFactory.DeleteFromCache(deleteFromCacheOptions)Dim cacheInfo As DocumentCacheInfo' Now get the info for this document, it should Not existcacheInfo = DocumentFactory.GetDocumentCacheInfo(Cache, documentId)Debug.Assert(IsNothing(cacheInfo))' Next, upload a document into this cacheDim UploadDocumentOptions As New UploadDocumentOptions()UploadDocumentOptions.Cache = CacheUploadDocumentOptions.DocumentId = documentIdUploadDocumentOptions.Name = "Leadtools.pdf"Dim uploadUri As Uri = DocumentFactory.BeginUpload(UploadDocumentOptions)Using stream As Stream = File.OpenRead(documentFile)Dim buffer(CType(stream.Length - 1, Integer)) As Bytestream.Read(buffer, 0, buffer.Length)DocumentFactory.UploadDocument(Cache, uploadUri, buffer, 0, buffer.Length)End UsingDocumentFactory.EndUpload(Cache, uploadUri)' Now check the info again, it should be there but Not loadedcacheInfo = DocumentFactory.GetDocumentCacheInfo(Cache, documentId)Console.WriteLine("After upload")Console.WriteLine(" DocumentId:" + cacheInfo.DocumentId)Console.WriteLine(" Name:" + cacheInfo.Name)Console.WriteLine(" IsLoaded:" + cacheInfo.IsLoaded.ToString())Debug.Assert(cacheInfo.DocumentId = documentId)Debug.Assert(cacheInfo.Name = "Leadtools.pdf")Debug.Assert(Not cacheInfo.IsLoaded)' Next load this documentDim LoadDocumentOptions As New LoadDocumentOptions()LoadDocumentOptions.Cache = CacheUsing document As LEADDocument = DocumentFactory.LoadFromUri(uploadUri, LoadDocumentOptions)' Save it to the cachedocument.AutoSaveToCache = Falsedocument.AutoDeleteFromCache = Falsedocument.SaveToCache()End Using' Now get its info again, it should be there And loadedcacheInfo = DocumentFactory.GetDocumentCacheInfo(Cache, documentId)Console.WriteLine("After load")Console.WriteLine(" DocumentId:" + cacheInfo.DocumentId)Console.WriteLine(" Name:" + cacheInfo.Name)Console.WriteLine(" IsLoaded:" + cacheInfo.IsLoaded.ToString())Debug.Assert(cacheInfo.DocumentId = documentId)Debug.Assert(cacheInfo.Name = "Leadtools.pdf")Debug.Assert(cacheInfo.IsLoaded)End Sub
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
