←Select platform

UploadDocumentUri Property

Summary

The URI of the uploaded document.

Syntax
C#
C++/CLI
Python
public Uri UploadDocumentUri { get; } 
public:  
   property Uri^ UploadDocumentUri 
   { 
      Uri^ get() 
   } 
UploadDocumentUri # get  (DocumentConverterJob) 

Property Value

The URI of the uploaded document.

Remarks

UploadDocumentUri will contain the URI of the final uploaded document if the job data was instructed to automatically upload the document when finished. Refer to DocumentConverterJobData.UploadDocumentOptions for more information and an example.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
using Leadtools.Svg; 
using LeadtoolsExamples.Common; 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Document.Converter; 
using Leadtools.Annotations.Rendering; 
 
public static void UploadToCacheExample() 
{ 
   // We will be converting this TIFF file to PDF 
   string imageUrl = "https://demo.leadtools.com/images/tiff/ocr.tif"; 
   // Download the final document to this file 
   string outputFile = @"c:\temp\output.pdf"; 
   string inputDocumentId = null; 
   Uri outputDocumentUrl = null; 
 
   // Setup the cache 
   FileCache cache = new FileCache(); 
   cache.CacheDirectory = @"c:\temp\cache"; 
 
   // Load the document and save it to the cache 
   var loadDocumentOptions = new LoadDocumentOptions(); 
   loadDocumentOptions.Cache = cache; 
   Console.WriteLine("Saving input document into the cache"); 
   using (LEADDocument document = DocumentFactory.LoadFromUri(new Uri(imageUrl), loadDocumentOptions)) 
   { 
      // Store the document ID to use it later 
      inputDocumentId = document.DocumentId; 
      // Make sure the document persist on the cache after we dispose it 
      document.AutoSaveToCache = false; 
      document.AutoDeleteFromCache = false; 
      document.SaveToCache(); 
   } 
 
   // Convert the document to PDF and automatically upload it 
   using (var ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      ocrEngine.Startup(null, null, null, null); 
      using (var documentConverter = new DocumentConverter()) 
      { 
         documentConverter.SetOcrEngineInstance(ocrEngine, false); 
         var jobData = new DocumentConverterJobData(); 
         // Input 
         jobData.DocumentId = inputDocumentId; 
         jobData.Cache = cache; 
 
         // Output, upload to the same cache as a new document 
         var uploadDocumentOptions = new UploadDocumentOptions(); 
         uploadDocumentOptions.Cache = cache; 
         jobData.UploadDocumentOptions = uploadDocumentOptions; 
 
         // Options 
         jobData.DocumentFormat = DocumentFormat.Pdf; 
 
         // Run 
         Console.WriteLine("Converting {0} and uploading", inputDocumentId); 
         var job = documentConverter.Jobs.CreateJob(jobData); 
         documentConverter.Jobs.RunJob(job); 
 
         Console.WriteLine(job.Status); 
         if (job.Status != DocumentConverterJobStatus.Aborted) 
         { 
            Console.WriteLine("Downloading {0}", job.UploadDocumentUri); 
            // Download it from the cache to the output file 
            using (var stream = File.Create(outputFile)) 
            { 
               var downloadDocumentOptions = new DownloadDocumentOptions(); 
               downloadDocumentOptions.Cache = cache; 
               downloadDocumentOptions.DocumentId = job.UploadDocumentUri.ToString(); 
               downloadDocumentOptions.Offset = 0; 
               downloadDocumentOptions.Length = -1; 
               downloadDocumentOptions.Stream = stream; 
               DocumentFactory.DownloadDocument(downloadDocumentOptions); 
            } 
 
            outputDocumentUrl = job.UploadDocumentUri; 
 
            Process.Start(outputFile); 
         } 
      } 
   } 
 
   // Clean up 
   var deleteFromCacheOptions = new LoadFromCacheOptions(); 
   deleteFromCacheOptions.Cache = cache; 
   if (inputDocumentId != null) 
   { 
      deleteFromCacheOptions.DocumentId = inputDocumentId; 
      DocumentFactory.DeleteFromCache(deleteFromCacheOptions); 
   } 
   if (outputDocumentUrl != null) 
   { 
      deleteFromCacheOptions.DocumentId = outputDocumentUrl.ToString(); 
      DocumentFactory.DeleteFromCache(deleteFromCacheOptions); 
   } 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Converter Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.