←Select platform

LoadSvgAsyncCompleted Event

Indicates that an asynchronous load SVG operation has been completed.
public event EventHandler<CodecsLoadSvgAsyncCompletedEventArgs> LoadSvgAsyncCompleted 
synchronized public void addLoadSvgAsyncCompletedListener(CodecsLoadSvgAsyncCompletedListener listener) 
synchronized public void removeLoadSvgAsyncCompletedListener(CodecsLoadSvgAsyncCompletedListener listener) 
event EventHandler<CodecsLoadSvgAsyncCompletedEventArgs^>^ LoadSvgAsyncCompleted 
def LoadSvgAsyncCompleted(sender,e): # sender: RasterCodecs e: CodecsLoadSvgAsyncCompletedEventArgs 
Event Data

The event handler receives an argument of type CodecsLoadSvgAsyncCompletedEventArgs containing data related to this event. The following CodecsLoadSvgAsyncCompletedEventArgs properties provide information specific to this event.

Cancelled (Inherited from System.ComponentModel.AsyncCompletedEventArgs)Gets a value indicating whether an asynchronous operation has been canceled.
Document Gets the ISvgDocument object being loaded.
UserState (Inherited from System.ComponentModel.AsyncCompletedEventArgs)Gets the unique identifier for the asynchronous task.

NOTE: This topic is part of RasterCodecs Async support using the .NET System.ComponentMode.AsyncOperation model. For .NET async/await support this type/member is not used. Instead, refer to RasterCodecs Async Operations.

The RasterCodecs class supports loading SVG from image files asynchronously using the LoadSvgAsync methods. When calling any of these methods, the caller thread will not be blocked and the method will return instantly.

When the RasterCodecs object finishes loading the SVG, the LoadSvgAsyncCompleted event will occur when the operation is finished (or when an error occur).

The LoadSvgAsyncCompleted event uses a data argument object of type CodecsLoadSvgAsyncCompletedEventArgs. This class contains the following properties:

Property Description
CodecsLoadSvgAsyncCompletedEventArgs.Uri, CodecsLoadSvgAsyncCompletedEventArgs.Stream and CodecsLoadSvgAsyncCompletedEventArgs.FileName

Contains the URI, stream or file name passed to the method that initialized this asynchronous operation.

Only one of these properties can be a valid value (not a null reference) at any time The property that contains a valid reference depends on what version of LoadSvgAsync method has been called.

For example, if LoadSvgAsync(Uri uri, int pageNumber, CodecsLoadSvgOptions options, object userState) is being called, the Uri will contain the same URI passed to the method while Stream and FileName will both be null. If LoadSvgAsync(String fileName, int pageNumber, CodecsLoadSvgOptions options, object userState) is being called, the FileName will contain the same file name string value passed to the method while Uri and Stream will both be null and so on.


Contains the ISvgDocument instance that contains the SVG data of the page being loaded. When the asynchronous operation completes, the LoadSvgAsyncCompleted event will fire and Document will contain the final and ready to use SVG object. If an error occurs, this property will be set to null and the object is disposed internally by the toolkit.


Contains any errors that might have occurred during the asynchronous operation. You must check this value when the LoadSvgAsyncCompleted event fires and make sure it does not contain a valid Exception object.


Contains a value indicating whether an asynchronous operation has been canceled. For example, by calling CancelAsync when using RasterCodecs.LoadSvgAsync with a URL.

For more information, refer to Working With SVG.


This example will load a page from a URL as SVG:

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
public void LoadSvgAsyncExample() 
   // Address of a document thats supports loading as SVG, for example, a DOCX file 
   string address = @"http://localhost/images/examples/leadtools.docx"; 
   EventHandler<CodecsLoadSvgAsyncCompletedEventArgs> loadSvgAsyncCompleted = null; 
   loadSvgAsyncCompleted = (sender, e) => 
      var thisCodecs = sender as RasterCodecs; 
      // Remove the handler 
      thisCodecs.LoadSvgAsyncCompleted -= loadSvgAsyncCompleted; 
      Debug.WriteLine("Loading from {0} is done", e.Uri); 
      SvgDocument svgDocument = e.Document as SvgDocument; 
      if (svgDocument != null) 
         // Show its size 
         if (!svgDocument.Bounds.IsValid) 
         Debug.WriteLine("Bounds: {0}", svgDocument.Bounds.Bounds); 
      else if (e.Error != null) 
         // Error 
      // Clean up 
   var codecs = new RasterCodecs(); 
   // Set 300 as the default value for loading document files 
   codecs.Options.RasterizeDocument.Load.Resolution = 300; 
   codecs.LoadSvgAsyncCompleted += loadSvgAsyncCompleted; 
   codecs.LoadSvgAsync(new Uri(address), 1, null, null); 
import java.io.*; 
import java.net.*; 
import java.nio.file.Paths; 
import java.util.*; 
import java.time.Instant; 
import java.time.Duration; 
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.codecs.*; 
import leadtools.codecs.RasterCodecs.FeedCallbackThunk; 
import leadtools.drawing.internal.*; 
import leadtools.imageprocessing.*; 
import leadtools.imageprocessing.color.ChangeIntensityCommand; 
import leadtools.svg.*; 
public void loadSvgAsyncCompletedExample() throws URISyntaxException, IOException { 
   // Address of a document thats supports loading as SVG, for example, a DOCX file 
   String address = "http://localhost/images/examples/leadtools.docx"; 
   RasterCodecs codecs = new RasterCodecs(); 
   // Set 300 as the default value for loading document files 
   ILeadStream uriStream = LeadStreamFactory.create(new URI(address)); 
   codecs.loadSvgAsync(uriStream, 1, null, null); 
CodecsLoadSvgAsyncCompletedListener loadSvgAsyncCompleted = new CodecsLoadSvgAsyncCompletedListener() { 
   public void onLoadSvgAsyncCompleted(CodecsLoadSvgAsyncCompletedEvent e) { 
      RasterCodecs thisCodecs = (RasterCodecs) e.getSource(); 
      // Remove the handler 
      System.out.println("Loading is done"); 
      SvgDocument svgDocument = (SvgDocument) e.getDocument(); 
      if (svgDocument != null) { 
         // Show its size 
         if (!svgDocument.getBounds().isValid()) { 
         System.out.printf("Bounds: %s", svgDocument.getBounds().getBounds()); 
      } else if (e.getError() != null) { 
         // Error 
      // Clean up 

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.Codecs Assembly

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