←Select platform

LoadFromStream Method

Summary

Creates an SvgDocument object from a stream containing SVG data.

Syntax

C#
VB
Java
Objective-C
C++
public static Leadtools.Svg.SvgDocument LoadFromStream(  
   Stream stream, 
   Leadtools.Svg.SvgLoadOptions options 
) 
Public Shared Function LoadFromStream( _ 
   ByVal stream As Stream, _ 
   ByVal options As Leadtools.Svg.SvgLoadOptions _ 
) As Leadtools.Svg.SvgDocument 
- (nullable instancetype)initWithStream:(LTLeadStream *)stream 
                                options:(nullable LTSvgLoadOptions *)options 
                                  error:(NSError **)error 
public static SvgDocument loadFromStream(InputStream stream, SvgLoadOptions options)
public: 
static Leadtools.Svg.SvgDocument^ LoadFromStream(  
   Stream^ stream, 
   Leadtools.Svg.SvgLoadOptions^ options 
) 

Parameters

stream
The stream containing SVG data

options
Options to use during load. If this parameter is null, then a default SvgLoadOptions object will be used.

Return Value

The SvgDocument object this method creates.

Remarks

To get and set information about a document's bounds and resolution, refer to SVG Size, Bounds and Flat.

Example

This example will load a SVG file from a web stream and show its properties

C#
VB
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Drawing 
Imports Leadtools.Forms.DocumentWriters 
Imports Leadtools.Svg 
 
Public Shared Sub SvgLoadFromStreamExample() 
   ' Assume the SVG files are located here 
   Dim addressTemplate As String = "http://localhost/images/examples/page1.svg" 
   ' Get a stream to it 
   Dim request As WebRequest = WebRequest.Create(New Uri(addressTemplate)) 
   Using response As WebResponse = request.GetResponse() 
      Dim stream As Stream = response.GetResponseStream() 
 
      ' Load it 
      Using document As SvgDocument = SvgDocument.LoadFromStream(stream, Nothing) 
         ' Prepare it 
         If Not document.IsFlat Then 
            document.Flat(Nothing) 
         End If 
         If Not document.Bounds.IsValid Then 
            document.CalculateBounds(False) 
         End If 
 
         ' Show its properties 
         Console.WriteLine("Bounds: " + document.Bounds.Bounds.ToString()) 
         Console.WriteLine("Resolution: " + document.Bounds.Resolution.ToString()) 
      End Using 
   End Using 
End Sub 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.Forms.DocumentWriters; 
using Leadtools.Svg; 
 
       
public void SvgLoadFromStreamExample() 
{ 
   // Assume the SVG files are located here 
   string addressTemplate = @"http://localhost/images/examples/page1.svg"; 
   // Get a stream to it 
   WebRequest request = WebRequest.Create(new Uri(addressTemplate)); 
   using (WebResponse response = request.GetResponse()) 
   { 
      Stream stream = response.GetResponseStream(); 
 
      // Load it 
      using (SvgDocument document = SvgDocument.LoadFromStream(stream, null)) 
      { 
         // Prepare it 
         if (!document.IsFlat) 
            document.Flat(null); 
         if (!document.Bounds.IsValid) 
            document.CalculateBounds(false); 
 
         // Show its properties 
         Console.WriteLine("Bounds: " + document.Bounds.Bounds); 
         Console.WriteLine("Resolution: " + document.Bounds.Resolution); 
      } 
   } 
} 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Svg Assembly
Click or drag to resize