Clones (creates a copy) of an uploaded document in the cache.
public static Uri CloneDocument(ObjectCache sourceCache,ObjectCache targetCache,Uri sourceDocumentUri,CloneDocumentOptions options)
Public Shared Function CloneDocument(ByVal sourceCache As ObjectCache,ByVal targetCache As ObjectCache,ByVal sourceDocumentUri As Uri,ByVal options As CloneDocumentOptions) As Uri
public:static Uri^ CloneDocument(ObjectCache^ sourceCache,ObjectCache^ targetCache,Uri^ sourceDocumentUri,CloneDocumentOptions^ options)
sourceCache
The cache object containing the data for the source document. This value must not be null.
targetCache
The cache object that will contain the data for the destination document. This value must not be null and can be the same value as sourceCache to clone in the document in the same cache.
sourceDocumentUri
URI to the data of the source document in the cache. This must be in the format of an uploaded document in the cache (leadcache://documentId).
options
Options to use during cloning.
The URL to the uploaded data of the new newly created document if successful. This value is in the leadcache://documentId format.
This method can be used to clone the data of an uploaded document in the same or a separate cache.
This method performs the following:
Calls BeginUpload on the targetCache using DocumentId and CachePolicy of options.
Repeatedly calls DownloadDocument on sourceCache and UploadDocument on targetCache to download the document data from the source and upload it into the destination.
Repeatedly calls DownloadAnnotations on sourceCache and UploadAnnotations on targetCache to download the annotation data (if any) from the source and upload it into the destination.
Calls EndUpload on targetCache when done.
Returns the URL to the newly uploaded document in targetCache.
Use CloneDocument(ObjectCache,ObjectCache,string,CloneDocumentOptions) or CloneDocument(ObjectCache,string,CloneDocumentOptions) to clone an existing document in the same cache.
This example uploads a document into the cache and then makes a clone of the data.
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 FactoryCloneDocumentExample(){var documentUri = new Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf");// Setup a cacheFileCache cache = new FileCache();cache.CacheDirectory = @"c:\cache-dir";string documentId1;string documentId2;// Load a document into the cachevar loadDocumentOptions = new LoadDocumentOptions();loadDocumentOptions.Cache = cache;using (var document1 = DocumentFactory.LoadFromUri(documentUri, loadDocumentOptions)){// Get its document ID and save itdocumentId1 = document1.DocumentId;document1.AutoDeleteFromCache = false;document1.AutoSaveToCache = false;document1.SaveToCache();}// Clone it in the cachevar cloneDocumentOptions = new CloneDocumentOptions();using (var document2 = DocumentFactory.CloneDocument(cache, documentId1, cloneDocumentOptions)){// Get its document ID and save itdocumentId2 = document2.DocumentId;document2.AutoDeleteFromCache = false;document2.AutoSaveToCache = false;document2.SaveToCache();}// Ensure both documents are in the cacheDocumentCacheInfo cacheInfo;cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId1);Debug.Assert(cacheInfo != null);cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId2);Debug.Assert(cacheInfo != null);// Now delete the first documentvar deleteFromCacheOptions = new LoadFromCacheOptions();deleteFromCacheOptions.Cache = cache;deleteFromCacheOptions.DocumentId = documentId1;DocumentFactory.DeleteFromCache(deleteFromCacheOptions);cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId1);Debug.Assert(cacheInfo == null);// Or by loading it from the cache, it should be nullvar loadFromCacheOptions = new LoadFromCacheOptions();loadFromCacheOptions.Cache = cache;loadFromCacheOptions.DocumentId = documentId1;using (var document1 = DocumentFactory.LoadFromCache(loadFromCacheOptions)){Debug.Assert(document1 == null);}// And ensure that the cloned document is still usable by loading itloadFromCacheOptions = new LoadFromCacheOptions();loadFromCacheOptions.Cache = cache;loadFromCacheOptions.DocumentId = documentId2;using (var document2 = DocumentFactory.LoadFromCache(loadFromCacheOptions)){Debug.Assert(document2 != null);}// We are done, clean updeleteFromCacheOptions = new LoadFromCacheOptions();deleteFromCacheOptions.Cache = cache;deleteFromCacheOptions.DocumentId = documentId2;DocumentFactory.DeleteFromCache(deleteFromCacheOptions);}
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 FactoryCloneDocumentExample()Dim documentUri As New Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf")' Setup a cacheDim cache As New FileCache()cache.CacheDirectory = "c:\cache-dir"Dim documentId1 As StringDim documentId2 As String' Load a document into the cacheDim loadDocumentOptions As New LoadDocumentOptions()loadDocumentOptions.Cache = cacheUsing document1 As LEADDocument = DocumentFactory.LoadFromUri(documentUri, loadDocumentOptions)' Get its document ID And save itdocumentId1 = document1.DocumentIddocument1.AutoDeleteFromCache = Falsedocument1.AutoSaveToCache = Falsedocument1.SaveToCache()End Using' Clone it into the same cacheDim cloneDocumentOptions As New CloneDocumentOptions()Using document2 As LEADDocument = DocumentFactory.CloneDocument(cache, documentId1, cloneDocumentOptions)' Get its document ID And save itdocumentId2 = document2.DocumentIddocument2.AutoDeleteFromCache = Falsedocument2.AutoSaveToCache = Falsedocument2.SaveToCache()End Using' Ensure both documents are in the cacheDim cacheInfo As DocumentCacheInfocacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId1)Debug.Assert(Not IsNothing(cacheInfo))cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId2)Debug.Assert(Not IsNothing(cacheInfo))' Now delete the first documentDim loadFromCacheOptions As New LoadFromCacheOptionsloadFromCacheOptions.Cache = cacheloadFromCacheOptions.DocumentId = documentId1DocumentFactory.DeleteFromCache(loadFromCacheOptions)cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, documentId1)Debug.Assert(IsNothing(cacheInfo))' Or by loading it from the cache, it should be nullloadFromCacheOptions = New LoadFromCacheOptionsloadFromCacheOptions.Cache = cacheloadFromCacheOptions.DocumentId = documentId1Using document1 As LEADDocument = DocumentFactory.LoadFromCache(loadFromCacheOptions)Debug.Assert(IsNothing(document1))End Using' And ensure that the cloned document Is still usable by loading itloadFromCacheOptions = New LoadFromCacheOptionsloadFromCacheOptions.Cache = cacheloadFromCacheOptions.DocumentId = documentId2Using document2 As LEADDocument = DocumentFactory.LoadFromCache(loadFromCacheOptions)Debug.Assert(Not IsNothing(document2))End Using' We are done, delete itDim deleteFromCacheOptions As New LoadFromCacheOptionsdeleteFromCacheOptions.Cache = cachedeleteFromCacheOptions.DocumentId = documentId2DocumentFactory.DeleteFromCache(deleteFromCacheOptions)End Sub
CloneDocument(ObjectCache,string,CloneDocumentOptions)
CloneDocument(ObjectCache,ObjectCache,string,CloneDocumentOptions)
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
