[SerializableAttribute()]public class SvgDocument : ISvgDocument, IDisposable, ISerializable
<SerializableAttribute()>Public Class SvgDocumentImplements ISvgDocument
@interface LTSvgDocument : NSObject <ISvgDocument, NSCopying, NSCoding> public class SvgDocument implements ISvgDocument, Serializable [SerializableAttribute()]public ref class SvgDocument : public ISvgDocument
The SvgDocument class represents a Scalable Vector Graphics (SVG) object. LEADTOOLS supports versions 1.* to 2.0 of the SVG specification.
The SvgDocument class implements System.Runtime.Serialization.ISerializable and fully supports .NET serialization.
The SvgDocument class implements System.IDisposable. You must use the .NET dispose pattern or call Dispose on the object after using it.
The SvgDocument class implements Leadtools.ISvgDocument and can be cast directly from the other LEADTOOLS methods that return an instance of that interface.
For more information about using SvgDocument, refer to Working With SVG.
This example will try to load the first page of each document in a folder as SVG. If successful, it will save the page as an SVG file.
using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.Forms.DocumentWriters;using Leadtools.Svg;using LeadtoolsExamples.Common;public void SvgDocumentExample(){// input directorystring inDir = ImagesPath.Path;// output directorystring outDir = Path.Combine(ImagesPath.Path, "svgpages");if (!Directory.Exists(outDir))Directory.CreateDirectory(outDir);using (var codecs = new RasterCodecs()){// Set 300 as the default value for loading document filescodecs.Options.RasterizeDocument.Load.Resolution = 300;codecs.ThrowExceptionsOnInvalidImages = false;// Get all the files from input directoryforeach (var srcFileName in Directory.EnumerateFiles(inDir)){Console.WriteLine("Checking {0}", srcFileName);using (var info = codecs.GetInformation(srcFileName, false)){// We can load as SVG if its document or vector (skipping SVG files themselves)if (info.Format != RasterImageFormat.Unknown && // valid formatinfo.Format != RasterImageFormat.Svg && // not svg(info.Document.IsDocumentFile || // a documentinfo.Vector.IsVectorFile)) // or vector{// try to load the first page as SVGtry{using (SvgDocument svgDocument = codecs.LoadSvg(srcFileName, 1, null) as SvgDocument){// Save it to diskstring name = Path.GetFileName(srcFileName).Replace(".", "-");name = Path.ChangeExtension(name, "svg");string dstFileName = Path.Combine(outDir, name);Console.WriteLine("Saving to {0}", dstFileName);svgDocument.SaveToFile(dstFileName, null);}}catch (Exception ex){Console.WriteLine(ex.Message);}}}}}}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.DrawingImports Leadtools.Forms.DocumentWritersImports Leadtools.SvgPublic Shared Sub SvgDocumentExample()' input directoryDim inDir As String = Common.ImagesPath.Path' output directoryDim outDir As String = Path.Combine(Common.ImagesPath.Path, "svgpages")If Not Directory.Exists(outDir) ThenDirectory.CreateDirectory(outDir)End IfUsing codecs As New RasterCodecs()' Set 300 as the default value for loading document filescodecs.Options.RasterizeDocument.Load.Resolution = 300codecs.ThrowExceptionsOnInvalidImages = False' Get all the files from input directoryFor Each srcFileName As String In Directory.EnumerateFiles(inDir)Console.WriteLine("Checking {0}", srcFileName)Using info As CodecsImageInfo = codecs.GetInformation(srcFileName, False)' We can load as SVG if its document or vector (skipping SVG files themselves)If info.Format <> RasterImageFormat.Unknown AndAlsoinfo.Format <> RasterImageFormat.Svg AndAlso(info.Document.IsDocumentFile OrElseinfo.Vector.IsVectorFile) Then' try to load the first page as SVGTryUsing svgDocument As SvgDocument = DirectCast(codecs.LoadSvg(srcFileName, 1, Nothing), SvgDocument)' Save it to diskDim name As String = Path.GetFileName(srcFileName).Replace(".", "-")name = Path.ChangeExtension(name, "svg")Dim dstFileName As String = Path.Combine(outDir, name)Console.WriteLine("Saving to {0}", dstFileName)svgDocument.SaveToFile(dstFileName, Nothing)End UsingCatch ex As ExceptionConsole.WriteLine(ex.Message)End TryEnd IfEnd UsingNextEnd UsingEnd Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
