←Select platform

DocumentId Property


Unique identifier of this document.

public string DocumentId { get; } 
Public ReadOnly Property DocumentId() As String 
   property String^ DocumentId 
      String^ get() 
public String getDocumentId() 

Property Value

The unique identifier of this document.


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.


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.

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; 
	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 
public void PrintOutDocumentInfo(LEADDocument document) 
	Console.WriteLine("  DocumentId:" + document.DocumentId); 
	if (document.Uri != null) 
		Console.WriteLine("  Uri:" + document.Uri); 
	Console.WriteLine("  Name:" + document.Name); 
	Console.WriteLine("  CacheStatus:" + document.CacheStatus); 
	Console.WriteLine("  LastCacheSyncTime:" + document.LastCacheSyncTime); 
	Console.WriteLine("  IsReadOnly:" + document.IsReadOnly); 
	Console.WriteLine("  IsLocal:" + document.IsLocal); 
	Console.WriteLine("  MimeType:" + document.MimeType); 
	Console.WriteLine("  IsEncrypted:" + document.IsEncrypted); 
	Console.WriteLine("  IsDecrypted:" + document.IsDecrypted); 
	Console.WriteLine("  UserData:" + document.UserData); 
	Console.WriteLine("  HasCache:" + document.HasCache); 
	Console.WriteLine("  AutoDeleteFromCache:" + document.AutoDeleteFromCache); 
	foreach (var item in document.Metadata) 
		Console.WriteLine("  {0} {1}", item.Key, item.Value); 
	Console.WriteLine("  Count:" + document.Documents.Count); 
	foreach (var childDocument in document.Documents) 
		Console.WriteLine("    Name:" + childDocument.Name); 
	Console.WriteLine("  Count:" + document.Pages.Count); 
	for (var pageNumber = 1; pageNumber <= document.Pages.Count; pageNumber++) 
		var page = document.Pages[pageNumber - 1]; 
		Console.WriteLine("    PageNumber:" + pageNumber); 
		Console.WriteLine("      OriginalPageNumber:" + page.OriginalPageNumber); 
		Console.WriteLine("      OriginalDocumentName:" + page.Document.Name); 
		Console.WriteLine("      Size:{0}", page.Size); 
		public ObjectCache GetCache() 
	// Create a LEADTOOLS FileCache object 
	var cacheDir = Path.Combine(LEAD_VARS.ImagesDir, "cache"); 
	if (Directory.Exists(cacheDir)) 
		Directory.Delete(cacheDir, true); 
	var cache = new FileCache(); 
	cache.CacheDirectory = cacheDir; 
	return cache; 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Document.Writer 
Imports Leadtools.Svg 
Imports Leadtools.Document 
Imports Leadtools.Caching 
Imports Leadtools.Annotations.Engine 
Imports Leadtools.Barcode 
Imports Leadtools.Ocr 
Imports LeadtoolsDocumentExamples.LeadtoolsExamples.Common 
Imports Leadtools.Document.Converter 
Public Shared Sub DocumentIdExample() 
   Dim cache As ObjectCache = GetCache() 
   Dim policy As CacheItemPolicy = New CacheItemPolicy() 
   policy.AbsoluteExpiration = DateTime.Now + New TimeSpan(0, 0, 10) 
   policy.SlidingExpiration = New TimeSpan(0, 0, 10) 
   Dim options As LoadDocumentOptions = New LoadDocumentOptions() 
   options.CachePolicy = policy 
   options.Cache = cache 
   Dim documentId As String = Nothing 
   Using document As LEADDocument = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.pdf"), options) 
      document.AutoDeleteFromCache = False 
      documentId = document.DocumentId 
   End Using 
   Dim loadFromCacheOptions As New LoadFromCacheOptions 
   loadFromCacheOptions.Cache = cache 
   loadFromCacheOptions.DocumentId = documentId 
   Using document As LEADDocument = DocumentFactory.LoadFromCache(loadFromCacheOptions) 
      If document IsNot Nothing Then 
         'will be deleted 
         document.AutoDeleteFromCache = True 
      End If 
   End Using 
End Sub 
Target Platforms
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly

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