LoadFromMemory Method (original) (raw)

Summary

Creates an SvgDocument object from data saved in a memory buffer.

Syntax

C#

Objective-C

C++/CLI

Java

Python

- (nullable instancetype)initWithData:(NSData *)data options:(nullable LTSvgLoadOptions *)_options_ error:(NSError **)error

Parameters

buffer
Buffer containing the SVG data.

offset
0-based offset into the buffer where the data begins.

length
Number of bytes to read.

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

using Leadtools; using Leadtools.Codecs; using Leadtools.Drawing; using Leadtools.Forms.DocumentWriters; using Leadtools.Svg; using Leadtools.Document.Writer; public void SvgLoadFromMemoryExample() { // Assume the SVG file is located here string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Page1.svg"); // Load the file into memory byte[] data = File.ReadAllBytes(srcFileName); // Load the SVG using (SvgDocument document = SvgDocument.LoadFromMemory(data, 0, data.Length, 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); } } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }