Click here to Skip to main content
Click here to Skip to main content

An SVG framework in C# and an SVG-GDI+ bridge

, 8 Mar 2003
Rate this:
Please Sign up or sign in to vote.
Svg.Net is a C# framework for creating SVG images. A GDI-SVG bridge is implemented on top of it.
<!-- Add the rest of your HTML here -->

SvgNet & SvgGdi

SvgNet is a C# library designed to facilitate the processing and particularly the creation of SVG documents in C#.
The project homepage is here. Source on the homepage may be more recent than The Code Project copy.

What it does

SvgNet consists of the following parts:

Classes to represent SVG elements and SVG types

SvgNet contains a family of classes that represent SVG elements (e.g. ellipse or tspan) and SVG types (e.g. a transformation list, a style, or a path description). The SVG types are provided with operators to make constructing and modifying SVG documents easy. For example, to change some properties of a style you can do:
myEllipse.Style = new Style("fill:red");
myEllipse.Style.Set("opacity", 0.5);
myEllipse.Style += "stroke:black";

Classes to read, write and copy SVG scenes

To get an SVG string from a tree of SVG elements you have created is as simple as this:
SvgElement myRootElement = SvgFactory.ReadSvgString(s);
s = myRootElement.WriteSvgString(); 
XML output can use entities to reduce the size and increase the legibility of the document.

The SvgFactory class also contains methods to make a deep copy of any SVG node and its descendants. All SVG types and elements are cloneable.

The Svg-Gdi bridge

The SvgGdi bridge is a set of classes that use SvgNet to translate between SVG and GDI+. What this means is that any code that uses GDI+ to draw graphics can easily output SVG as well, simply by plugging in the SvgGraphics object. This object is exactly the same as a regular .NET Graphics object, but creates an SVG tree. Even things like hatched fills and line anchors are implemented. The irritatingly old-fashioned 'current transformation' system of GDI+ is implemented by creating nested SVG group elements, resulting in SVG output that's a bit cleaner than the corresponding GDI+ metafile in some ways.

SvgGdi is the main use for SvgNet, although other things (a collection of basic shapes, maybe charting tools) may be built on SvgNet in the future.


The SvgNet class libraries are documented in this help package. Additionally, there are two example applications bundled with SvgNet:
  • SvgDocTest -- test application that reads and writes documents and constructs an SVG document. This application is both an example and test system.
  • SvgGdiTest -- application that draws various scenes with SVG and GDI+. It is both an example of SvgGdi use, and a test of how accurate SvgGdi's emulation of GDI+ is.

The SvgNet Project

SvgNet is an Open Source project under a BSD-like license (license terms are reproduced in every SvgNet source file). SvgNet is copyright 2003 RiskCare Ltd.

The SvgNet project home page is here.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ben Peterson
Web Developer
United Kingdom United Kingdom
My interests are software engineering, Japanese, and talking about how good things used to be back in the good old days.
Favorite Toy:

Comments and Discussions

Questionhomepage here PinmemberDamianDixon23-Oct-14 0:14 
QuestionProject homepage not accessible PinmemberPie and Ale6-Dec-13 2:27 
BugIncompatible with some locale Pinmemberlill.LEIF2-Jun-12 23:30 
GeneralAcessViolationException setting the SRC property PinmemberJames Darlington27-Oct-10 12:44 
GeneralPlease provide the sample code... to deal with the file having dynamic element entries.. using XmlAttributeCollection...using C# PinmemberNikkiee25-Jun-09 13:04 
Generalremove and insert the another attribute PinmemberNikkiee20-Jun-09 13:53 
GeneralStack Overflow on complex pages PinmemberFranz Fiala12-Apr-09 21:45 
GeneralIncompatible output, not standard svg Pinmembervaleriob24-Nov-08 2:24 
QuestionAnybody can put an example to read a SVG file with this library? PinmemberMarcosjgr12-Sep-08 8:47 
AnswerRe: Anybody can put an example to read a SVG file with this library? PinmemberNikkiee10-Jun-09 16:16 
GeneralRe: Anybody can put an example to read a SVG file with this library? PinmemberNikkiee10-Jun-09 16:19 
AnswerRe: Anybody can put an example to read a SVG file with this library? PinmemberMarcosjgr15-Jun-09 8:34 
GeneralRe: Anybody can put an example to read a SVG file with this library? PinmemberNikkiee20-Jun-09 13:47 
GeneralWarnings and Excepetions, please Help. PinmemberMarcosjgr8-Sep-08 16:30 
GeneralRe: Warnings and Excepetions, please Help. PinmemberMarcosjgr12-Sep-08 8:38 
QuestionSvgAElement Pinmemberaliov_857-Nov-07 1:04 
AnswerRe: SvgAElement Pinmemberaliov_8519-Nov-07 6:44 2.0 and SVGNet _VERY URGENT_PLEASE Pinmemberaliov_8516-Oct-07 23:23 
AnswerRe: 2.0 and SVGNet _VERY URGENT_PLEASE Pinmemberaliov_8519-Nov-07 6:39 
Generalerror in svgCtl.SRC = "c:\\temp\\foo.svg" PinmemberRazik3-Apr-07 23:37 
GeneralNew Home Page Location Pinmemberlogan13373-Mar-07 16:29 
GeneralRe: New Home Page Location Pinmemberalreadyused5-Aug-08 10:52 
GeneralGood Pinmembernorm .net28-Feb-07 2:10 
QuestionStill alive? PinmemberRazputin5-Feb-07 7:17 
AnswerRe: Still alive? PinmemberBen Peterson5-Feb-07 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150302.1 | Last Updated 9 Mar 2003
Article Copyright 2003 by Ben Peterson
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid