←Select platform

SvgDocument Class


Represents a Scalable Vector Graphics (SVG) document.


public class SvgDocument : Leadtools.Leadtools.ISvgDocument 
Public Class SvgDocument  
   Implements Leadtools.Leadtools.ISvgDocument 
@interface LTSvgDocument : NSObject <ISvgDocument, NSCopying, NSCoding>
public class SvgDocument implements ISvgDocument, Serializable
public ref class SvgDocument : public Leadtools.Leadtools.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.

Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Drawing 
Imports Leadtools.Forms.DocumentWriters 
Imports Leadtools.Svg 
Public Shared Sub SvgDocumentExample() 
   ' input directory 
   Dim inDir As String = Common.ImagesPath.Path 
   ' output directory 
   Dim outDir As String = Path.Combine(Common.ImagesPath.Path, "svgpages") 
   If Not Directory.Exists(outDir) Then 
   End If 
   Using codecs As New RasterCodecs() 
      ' Set 300 as the default value for loading document files 
      codecs.Options.RasterizeDocument.Load.Resolution = 300 
      codecs.ThrowExceptionsOnInvalidImages = False 
      ' Get all the files from input directory 
      For 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 AndAlso _ 
               info.Format <> RasterImageFormat.Svg AndAlso _ 
               (info.Document.IsDocumentFile OrElse _ 
               info.Vector.IsVectorFile) Then 
               ' try to load the first page as SVG 
                  Using svgDocument As SvgDocument = DirectCast(codecs.LoadSvg(srcFileName, 1, Nothing), SvgDocument) 
                     ' Save it to disk 
                     Dim 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 Using 
               Catch ex As Exception 
               End Try 
            End If 
         End Using 
   End Using 
End Sub 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.Forms.DocumentWriters; 
using Leadtools.Svg; 
public  void SvgDocumentExample() 
   // input directory 
   string inDir = ImagesPath.Path; 
   // output directory 
   string outDir = Path.Combine(ImagesPath.Path, "svgpages"); 
   if (!Directory.Exists(outDir)) 
   using (var codecs = new RasterCodecs()) 
      // Set 300 as the default value for loading document files 
      codecs.Options.RasterizeDocument.Load.Resolution = 300; 
      codecs.ThrowExceptionsOnInvalidImages = false; 
      // Get all the files from input directory 
      foreach (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 format 
               info.Format != RasterImageFormat.Svg && // not svg 
               (info.Document.IsDocumentFile ||   // a document 
               info.Vector.IsVectorFile)) // or vector 
               // try to load the first page as SVG 
                  using (SvgDocument svgDocument = codecs.LoadSvg(srcFileName, 1, null) as SvgDocument) 
                     // Save it to disk 
                     string 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) 


Target Platforms

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