Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.3
|
Leadtools.Documents Namespace > Document Class : DocumentId Property |
public string DocumentId {get;}
'Declaration
Public ReadOnly Property DocumentId As String
public String getDocumentId()
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.
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.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.Forms.DocumentWriters Imports Leadtools.Svg Imports Leadtools.Documents Imports Leadtools.Caching Imports Leadtools.Annotations.Core Imports Leadtools.Barcode Imports Leadtools.Forms.Ocr <TestMethod()> _ Public Sub DocumentIdExample() DocumentFactory.Cache = CreateCache() 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 Dim documentId As String = Nothing Using document As Document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.pdf"), options) document.AutoDeleteFromCache = False documentId = document.DocumentId document.SaveToCache() End Using Using document As Document = DocumentFactory.LoadFromCache(documentId) If document IsNot Nothing Then 'will be deleted document.AutoDeleteFromCache = True End If End Using End Sub
using Leadtools; using Leadtools.Codecs; using Leadtools.Forms.DocumentWriters; using Leadtools.Svg; using Leadtools.Documents; using Leadtools.Caching; using Leadtools.Annotations.Core; using Leadtools.Forms.Ocr; using Leadtools.Barcode; [TestMethod] public void DocumentIdExample() { DocumentFactory.Cache = CreateCache(); 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.CachePolicy = policy; string documentId = null; using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.pdf"), options)) { document.AutoDeleteFromCache = false; documentId = document.DocumentId; document.SaveToCache(); } using (var document = DocumentFactory.LoadFromCache(documentId)) { if (null != document) { document.AutoDeleteFromCache = true;//will be deleted } } }