User ID associated with this document.
public string UserId { get; set; }
The user ID associated with this LEADDocument. The default value is null.
This value is not required and not used directly by LEADTOOLS. User programs can set this value to the ID or name of the currently logged in user for application specific tracking purposes and authentication purposes.
If a value is set in UserId then it will be set in DocumentHistoryItem.UserId if history tracking is enabled. Refer to Document Toolkit History Tracking for more information.
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";// DocumentHistory referencedocument.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();childDocument.Annotations.SetHistory(childDocument.Annotations.GetHistory());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);// Get each DocumentHistoryItemforeach (DocumentHistoryItem item in document.History.GetItems()){document.History.SetItems(null);Console.WriteLine(item);}// Enumerate through DocumentHistoryModifyTypeDocumentHistoryModifyType[] modifyType = (DocumentHistoryModifyType[])Enum.GetValues(typeof(DocumentHistoryModifyType));foreach (var type in modifyType){Console.WriteLine($"Type of modification: {type}");}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);}}