History tracking of LEADDocument.
[DataContractAttribute()]public class DocumentHistory
<DataContractAttribute()>Public Class DocumentHistory
public:[DataContractAttribute]ref class DocumentHistory
DocumentHistory manages the history of the document. It can be accessed through the History property of LEADDocument. It contains an internal list of DocumentHistoryItem objects for each modification or change that occurred in the document.
History tracking is enabled when the value of AutoUpdate is true.
The items can be retrieved, updated or cleared through GetItems, SetItems and Clear respectively.
For more information, refer to Document Toolkit History Tracking.
This example enables history tracking on a document and shows the results.
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 DocumentHistoryExample(){// Setup a cacheFileCache cache = new FileCache();cache.CacheDirectory = @"c:\cache-dir";// Create a new documentvar createOptions = new CreateDocumentOptions();const string documentId = "virtual";createOptions.Cache = cache;createOptions.DocumentId = documentId;using (var document = DocumentFactory.Create(createOptions)){document.Name = "Virtual";document.History.AutoUpdate = true;document.IsReadOnly = false;// Show its historyShowHistory("virtual", document);// Ensure it has no pagesDebug.Assert(document.Pages.Count == 0);Debug.Assert(document.Documents.Count == 0);// Add some pages// First add the first 2 pages from a PDF filevar loadOptions = new LoadDocumentOptions();loadOptions.Cache = cache;LEADDocument childDocument = DocumentFactory.LoadFromUri(new Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf"), loadOptions);childDocument.AutoDeleteFromCache = false;childDocument.SaveToCache();document.Pages.Add(childDocument.Pages[0]);document.Pages.Add(childDocument.Pages[1]);// Add an empty pagevar documentPage = document.Pages.CreatePage(LeadSizeD.Create(LEADDocument.UnitsPerInch * 8.5, LEADDocument.UnitsPerInch * 11), 300);document.Pages.Add(documentPage);// Add last 2 pages from a TIFF filechildDocument = DocumentFactory.LoadFromUri(new Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf"), loadOptions);childDocument.AutoDeleteFromCache = false;childDocument.SaveToCache();document.Pages.Add(childDocument.Pages[2]);document.Pages.Add(childDocument.Pages[3]);// Check the documentDebug.Assert(5 == document.Pages.Count);Debug.Assert(2 == document.Documents.Count);document.AutoDisposeDocuments = true;document.AutoDeleteFromCache = false;document.SaveToCache();}// Load it and show its historyvar loadFromCacheOptions = new LoadFromCacheOptions();loadFromCacheOptions.Cache = cache;loadFromCacheOptions.DocumentId = documentId;using (var document = DocumentFactory.LoadFromCache(loadFromCacheOptions)){ShowHistory("virtual pages added", document);// Clear the historydocument.History.Clear();}// Now, load the document from the cacheusing (var document = DocumentFactory.LoadFromCache(loadFromCacheOptions)){Debug.Assert(5 == document.Pages.Count);Debug.Assert(2 == document.Documents.Count);// Remove some pagesdocument.Pages.RemoveAt(0);document.Pages.RemoveAt(document.Pages.Count - 1);// And rotate anotherdocument.Pages[1].Rotate(90);Debug.Assert(3 == document.Pages.Count);Debug.Assert(2 == document.Documents.Count);ShowHistory("virtual pages removed and rotated", document);}// Clean upvar deleteFromCacheOptions = new LoadFromCacheOptions();deleteFromCacheOptions.Cache = cache;deleteFromCacheOptions.DocumentId = documentId;DocumentFactory.DeleteFromCache(deleteFromCacheOptions);}private static void ShowHistory(string message, LEADDocument document){Console.WriteLine("History " + message);var items = document.History.GetItems();foreach (var item in items){Console.WriteLine(" user:{0} timestamp:{1} comment:{2} modifyType:{3} pageNumber:{4}",item.UserId, item.Timestamp, item.Comment, item.ModifyType, item.PageNumber);}}
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 DocumentHistoryExample()' Setup a cacheDim cache As New FileCache()cache.CacheDirectory = "c:\cache-dir"' Create a New documentDim createOptions As New CreateDocumentOptions()Const documentId As String = "virtual"createOptions.Cache = cachecreateOptions.DocumentId = documentIdUsing document As LEADDocument = DocumentFactory.Create(createOptions)document.Name = "Virtual"document.History.AutoUpdate = Truedocument.IsReadOnly = False' Show its historyShowHistory("virtual", document)' Ensure it has no pagesDebug.Assert(document.Pages.Count = 0)Debug.Assert(document.Documents.Count = 0)' Add some pages' First add the first 2 pages from a PDF fileDim loadOptions As New LoadDocumentOptions()loadOptions.Cache = cacheDim childDocument As LEADDocument = DocumentFactory.LoadFromUri(New Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf"), loadOptions)childDocument.AutoDeleteFromCache = FalsechildDocument.SaveToCache()document.Pages.Add(childDocument.Pages(0))document.Pages.Add(childDocument.Pages(1))' Add an empty pageDim documentPage As DocumentPage = document.Pages.CreatePage(LeadSizeD.Create(LEADDocument.UnitsPerInch * 8.5, LEADDocument.UnitsPerInch * 11), 300)document.Pages.Add(documentPage)' Add last 2 pages from a TIFF filechildDocument = DocumentFactory.LoadFromUri(New Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf"), loadOptions)childDocument.AutoDeleteFromCache = FalsechildDocument.SaveToCache()document.Pages.Add(childDocument.Pages(2))document.Pages.Add(childDocument.Pages(3))' Check the documentDebug.Assert(5 = document.Pages.Count)Debug.Assert(2 = document.Documents.Count)document.AutoDisposeDocuments = Truedocument.AutoDeleteFromCache = Falsedocument.SaveToCache()End Using' Load it And show its historyDim loadFromCacheOptions As New LoadFromCacheOptionsloadFromCacheOptions.Cache = cacheloadFromCacheOptions.DocumentId = documentIdUsing document As LEADDocument = DocumentFactory.LoadFromCache(loadFromCacheOptions)ShowHistory("virtual pages added", document)' Clear the historydocument.History.Clear()End Using' Now, load the document from the cacheloadFromCacheOptions = New LoadFromCacheOptionsloadFromCacheOptions.Cache = cacheloadFromCacheOptions.DocumentId = documentIdUsing document As LEADDocument = DocumentFactory.LoadFromCache(loadFromCacheOptions)Debug.Assert(5 = document.Pages.Count)Debug.Assert(2 = document.Documents.Count)' Remove some pagesdocument.Pages.RemoveAt(0)document.Pages.RemoveAt(document.Pages.Count - 1)' And rotate anotherdocument.Pages(1).Rotate(90)Debug.Assert(3 = document.Pages.Count)Debug.Assert(2 = document.Documents.Count)ShowHistory("virtual pages removed and rotated", document)End Using' Clean upDim deleteFromCacheOptions As New LoadFromCacheOptionsdeleteFromCacheOptions.Cache = cachedeleteFromCacheOptions.DocumentId = documentIdDocumentFactory.DeleteFromCache(deleteFromCacheOptions)End SubPrivate Shared Sub ShowHistory(message As String, document As LEADDocument)Console.WriteLine("History " + message)Dim items As List(Of DocumentHistoryItem) = document.History.GetItems()For Each item As DocumentHistoryItem In itemsConsole.WriteLine(" user:{0} timestamp:{1} comment:{2} modifyType:{3} pageNumber:{4}",item.UserId, item.Timestamp, item.Comment, item.ModifyType, item.PageNumber)NextEnd 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
