←Select platform

LoadFromUriAsync Method

Summary

Loads a document asynchronously from existing data stored in a remote URL.

Syntax
C#
C++/CLI
Python
public static void LoadFromUriAsync( 
   Uri uri, 
   LoadDocumentAsyncOptions options 
) 
public:  
   static void LoadFromUriAsync( 
      System::Uri^ uri, 
      LoadDocumentAsyncOptions^ options 
   ) 
def LoadFromUriAsync(self,uri,options): 

Parameters

uri

Path to the URL containing the original document data. This value cannot be null.

options

Options to use when loading the document. This value cannot be null.

Remarks

This method might use the cache and will throw an exception if neither LoadDocumentOptions.Cache nor Cache was setup with a valid cache object if certain options are used.

LoadFromUriAsync will start loading the document in a separate thread and return control to the user immediately. The LoadDocumentAsyncOptions class contains the Progress and Completed events that can be used to track the progress of the load and be notified when the operation is completed.

Note that uri can point to a document stored in HTTP, HTTPS, FTP, or Disk file (using the file protocol).

LoadFromFile, LoadFromUri, LoadFromUriAsync and LoadFromStream creates a LEADDocument class from any supported image or document file format stored in a disk file, remote URL or stream. The returned object can then be used to retrieve any page as image or SVG, to obtain the text using SVG or OCR, use the annotations or the document structure such as links and bookmarks.

After the document is obtained, InternalObject will be to the internal LEADTOOLS object used with the document.

Refer to Loading Using LEADTOOLS Document Library for detailed information on how to use this method and the various options used.

Example
C#
Java
using Leadtools; 
using Leadtools.Caching; 
using Leadtools.Document; 
 
 
public void DocumentFactoryLoadFromUriAsyncExample() 
{ 
   AutoResetEvent finished = null; 
   EventHandler<LoadAsyncCompletedEventArgs> completed = null; 
   // LoadAsyncProgressEventArgs reference 
   EventHandler<LoadAsyncProgressEventArgs> progress = null; 
 
   completed = (sender, e) => 
   { 
      //Assert((int)e.UserState == 1); 
 
      if (e.Cancelled) 
         Console.WriteLine("Canceled"); 
      if (e.Error != null) 
         Console.WriteLine("Error:" + e.Error.Message); 
      if (e.Document == null) 
         Console.WriteLine("Document is null"); 
 
      var thisOptions = sender as LoadDocumentAsyncOptions; 
      thisOptions.Completed -= completed; 
 
      if (e.Document != null) 
      { 
         PrintOutDocumentInfo(e.Document); 
      } 
 
      finished.Set(); 
      Console.WriteLine("Done"); 
   }; 
 
   progress = (sender, f) => 
   { 
      Console.WriteLine(f.BytesReceived); 
      Console.WriteLine(f.IsCancelPending); 
      Console.WriteLine(f.TotalBytesToReceive); 
 
      var thisOptions = sender as LoadDocumentAsyncOptions; 
      thisOptions.Progress -= progress; 
   }; 
 
   var options = new LoadDocumentAsyncOptions(); 
   options.Completed += completed; 
 
   finished = new AutoResetEvent(false); 
   DocumentFactory.LoadFromUriAsync(new Uri("http://localhost/Leadtools.pdf"), options); 
   finished.WaitOne(); 
} 
 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.IOException; 
import java.io.InputStream; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.util.Calendar; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.caching.*; 
import leadtools.document.*; 
 
 
// LOAD FROM URI ASYNC DOES NOT EXIST 
Requirements

Target Platforms

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

Leadtools.Document Assembly

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