←Select platform

IsLoaded Property

Summary

Indicates whether the document has been loaded at least once.

Syntax
C#
C++/CLI
Python
public bool IsLoaded {get; set;} 
public:  
   property bool IsLoaded 
   { 
      bool get() 
      void set(bool value) 
   } 
IsLoaded # get and set (DocumentCacheInfo) 

Property Value

true if this document has been loaded at least once; otherwise, false.

Remarks

If the value of IsLoaded is false, then the document was uploaded to the cache but has not been loaded with DocumentFactory.LoadFromCache yet.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Barcode; 
using Leadtools.Document.Converter; 
 
public void GetDocumentCacheInfoExample() 
{ 
   string documentFile = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"); 
 
   // Setup a cache 
   FileCache cache = new FileCache(); 
   cache.CacheDirectory = @"c:\cache-dir"; 
 
   // We will use this document ID 
   const string documentId = "test-document"; 
 
   // Ensure that the document does not exist in the cache 
   var deleteFromCacheOptions = new LoadFromCacheOptions(); 
   deleteFromCacheOptions.Cache = cache; 
   deleteFromCacheOptions.DocumentId = documentId; 
   DocumentFactory.DeleteFromCache(deleteFromCacheOptions); 
 
   DocumentCacheInfo cacheInfo; 
 
   // Now get the info for this document, it should not exist 
   cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId); 
   Debug.Assert(cacheInfo == null); 
 
   // Next, upload a document into this cache 
   var 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 loaded 
   cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId); 
   // DocumentCacheInfo reference 
   Console.WriteLine("After upload"); 
   Console.WriteLine("   DocumentId:" + cacheInfo.DocumentId); 
   Console.WriteLine("   Name:" + cacheInfo.Name); 
   Console.WriteLine("   IsLoaded:" + cacheInfo.IsLoaded); 
   Console.WriteLine("   Annotations data length:" + cacheInfo.AnnotationsDataLength); 
   Console.WriteLine("   Document data length:" + cacheInfo.DocumentDataLength); 
   Console.WriteLine("   Has annotations:" + cacheInfo.HasAnnotations); 
   Console.WriteLine("   Has user token:" + cacheInfo.HasUserToken); 
   Console.WriteLine("   Is virtual:" + cacheInfo.IsVirtual); 
   Console.WriteLine("   Mime Type:" + cacheInfo.MimeType); 
   Console.WriteLine("   Mime Type status:" + cacheInfo.MimeTypeStatus); 
   Console.WriteLine("   Page count:" + cacheInfo.PageCount); 
   Debug.Assert(cacheInfo.DocumentId == documentId); 
   Debug.Assert(cacheInfo.Name == "Leadtools.pdf"); 
   Debug.Assert(!cacheInfo.IsLoaded); 
   Debug.Assert(cacheInfo.AnnotationsDataLength == 0); 
   Debug.Assert(cacheInfo.DocumentDataLength == 90301); 
   Debug.Assert(!cacheInfo.HasAnnotations); 
   Debug.Assert(!cacheInfo.HasUserToken); 
   Debug.Assert(!cacheInfo.IsVirtual); 
   Debug.Assert(cacheInfo.MimeType == null); 
   Debug.Assert(cacheInfo.MimeTypeStatus == DocumentMimeTypeStatus.Unspecified); 
   Debug.Assert(cacheInfo.PageCount == 0); 
 
   // Next load this document 
   var loadDocumentOptions = new LoadDocumentOptions(); 
   loadDocumentOptions.Cache = cache; 
   using (var document = DocumentFactory.LoadFromUri(uploadUri, loadDocumentOptions)) 
   { 
      // Save it to the cache 
      document.AutoSaveToCache = false; 
      document.AutoDeleteFromCache = false; 
      document.SaveToCache(); 
   } 
 
   // Now get its info again, it should be there and loaded 
   cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId); 
   Console.WriteLine("After load"); 
   Console.WriteLine("   DocumentId:" + cacheInfo.DocumentId); 
   Console.WriteLine("   Name:" + cacheInfo.Name); 
   Console.WriteLine("   IsLoaded:" + cacheInfo.IsLoaded); 
   Console.WriteLine("   Annotations data length:" + cacheInfo.AnnotationsDataLength); 
   Console.WriteLine("   Document data length:" + cacheInfo.DocumentDataLength); 
   Console.WriteLine("   Has annotations:" + cacheInfo.HasAnnotations); 
   Console.WriteLine("   Has user token:" + cacheInfo.HasUserToken); 
   Console.WriteLine("   Is virtual:" + cacheInfo.IsVirtual); 
   Console.WriteLine("   Mime Type:" + cacheInfo.MimeType); 
   Console.WriteLine("   Mime Type status:" + cacheInfo.MimeTypeStatus); 
   Console.WriteLine("   Page count:" + cacheInfo.PageCount); 
   Debug.Assert(cacheInfo.DocumentId == documentId); 
   Debug.Assert(cacheInfo.Name == "Leadtools.pdf"); 
   Debug.Assert(cacheInfo.IsLoaded); 
   Debug.Assert(cacheInfo.AnnotationsDataLength == 0); 
   Debug.Assert(cacheInfo.DocumentDataLength == 90301); 
   Debug.Assert(!cacheInfo.HasAnnotations); 
   Debug.Assert(!cacheInfo.HasUserToken); 
   Debug.Assert(!cacheInfo.IsVirtual); 
   Debug.Assert(cacheInfo.MimeType == "application/pdf"); 
   Debug.Assert(cacheInfo.MimeTypeStatus == DocumentMimeTypeStatus.Unspecified); 
   Debug.Assert(cacheInfo.PageCount == 5); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Document Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.