LoadFromStream Method (original) (raw)

Summary

Creates an SvgDocument object from a stream containing SVG data.

Syntax

C#

Objective-C

C++/CLI

Java

Python

- (nullable instancetype)initWithStream:(LTLeadStream *)_stream_ options:(nullable LTSvgLoadOptions *)_options_ error:(NSError **)error

public static SvgDocument loadFromStream(InputStream stream, 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.

Example

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

using Leadtools; using Leadtools.Codecs; using Leadtools.Drawing; using Leadtools.Forms.DocumentWriters; using Leadtools.Svg; using Leadtools.Document.Writer; 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); } } }