←Select platform

DocumentId Property

Summary

Unique identifier of this document.

Syntax
C#
C++/CLI
Java
Python
public string DocumentId { get; } 
public:  
   property String^ DocumentId 
   { 
      String^ get() 
   } 
public String getDocumentId() 
DocumentId # get  (LEADDocument) 

Property Value

The unique identifier of this document.

Remarks

This value is set by the framework when the document is initialized. The ID is important when using the document with the cache system and is the only value needed to re-construct completely the document from the cache. The current implementation of the Document library will pass the document ID as the "regionName" value for all cache operations.

Example

This example will show how to use DocumentId to save a document to the cache and then reload it then delete it from the cache.

C#
Java
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 DocumentIdExample() 
{ 
   var cache = GetCache(); 
 
   var policy = new CacheItemPolicy(); 
   policy.AbsoluteExpiration = DateTime.Now + new TimeSpan(0, 0, 10); 
   policy.SlidingExpiration = new TimeSpan(0, 0, 10); 
 
   var options = new LoadDocumentOptions(); 
   options.Cache = cache; 
   options.CachePolicy = policy; 
 
   string documentId = null; 
 
   using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"), options)) 
   { 
      document.AutoDeleteFromCache = false; 
      documentId = document.DocumentId; 
      document.SaveToCache(); 
   } 
 
   var loadFromCacheOptions = new LoadFromCacheOptions(); 
   loadFromCacheOptions.Cache = cache; 
   loadFromCacheOptions.DocumentId = documentId; 
   using (var document = DocumentFactory.LoadFromCache(loadFromCacheOptions)) 
   { 
      if (null != document) 
      { 
         document.AutoDeleteFromCache = true;//will be deleted 
      } 
   } 
} 
 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.FileOutputStream; 
import java.io.IOException; 
import java.net.MalformedURLException; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.net.URL; 
import java.nio.file.Files; 
import java.nio.file.Paths; 
import java.util.ArrayList; 
import java.util.Calendar; 
import java.util.List; 
import java.util.concurrent.Callable; 
import java.util.concurrent.ExecutorService; 
import java.util.concurrent.Executors; 
import java.util.concurrent.Future; 
import java.util.regex.Pattern; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.annotations.engine.*; 
import leadtools.barcode.*; 
import leadtools.caching.*; 
import leadtools.codecs.*; 
import leadtools.document.*; 
import leadtools.document.DocumentMimeTypes.UserGetDocumentStatusHandler; 
import leadtools.document.converter.*; 
import leadtools.document.writer.*; 
import leadtools.ocr.*; 
 
 
public void documentIdExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   FileCache cache = getCache(); 
 
   CacheItemPolicy policy = new CacheItemPolicy(); 
   Calendar calendar = Calendar.getInstance(); 
   calendar.add(Calendar.SECOND, 10); 
   policy.setAbsoluteExpiration(calendar.getTime()); 
   policy.setSlidingExpiration(10); 
 
   LoadDocumentOptions options = new LoadDocumentOptions(); 
   options.setCache(cache); 
   options.setCachePolicy(policy); 
 
   String documentId = null; 
 
   LEADDocument document = DocumentFactory.loadFromFile(combine(LEAD_VARS_IMAGES_DIR, "Leadtools.pdf"), options); 
 
   document.setAutoDeleteFromCache(false); 
   documentId = document.getDocumentId(); 
   document.saveToCache(); 
 
   LoadFromCacheOptions loadFromCacheOptions = new LoadFromCacheOptions(); 
   loadFromCacheOptions.setCache(cache); 
   loadFromCacheOptions.setDocumentId(documentId); 
   document = DocumentFactory.loadFromCache(loadFromCacheOptions); 
   if (null != document) { 
      document.setAutoDeleteFromCache(true);// will be deleted 
   } 
} 
Requirements

Target Platforms

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

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