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.
Documentation
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.
Hi everybody. I have Vista SP1 and VS 2008 in my pc. Of course, now I downloaded SVG Adobe too and SVG version 0.92.
I'm trying to compile this project but some errors occurs. My firts question is about the windows, maybe this project does not run here and maybe does not run with VS 2008 too. So if it runs please tell me what I need to do. Second. About the errors: First I Build the solution in VS2008 no errors happends but 708 warnings appears, here is one:
Warning 1 Missing XML comment for publicly visible type or member 'SvgNet.SvgElement._children' C:\Users\M\Documents\Proyectos\svgnet_src092\SvgNet\SvgNet\SvgElement.cs 59 23 SvgNet
Second. I select SvgDocTest as startup project so when I run the project a exceptions happends:
I reply myself. Well for all folks that use Vista, take care, because the adobe plug in does not working fine in this O.S. Use XP to compile this project.
while running the sample the above statement in SvgGdiTest project gives "Object reference not set to an instance of an object" error. I am using IDE vs2003 and .Net Framework v1.1. Kindly help.
Found this great lookin library whilst on my searches, I'm thinking of writing a .NET Framework Extension for SVG and just wanted to check whats been done. This article was posted a while ago whats the state of play these days? Ben you still about? tried following the links but they're dead.
I'm still alive and this library still works for rendering GDI+ calls to SVG -- but it's unlikely I'll ever do any more work on it. Thanks for your interest though
Is it possible that you create a sourceforge project for this? So maybe other people can join the project and develop it further? E.g. for me it's useless only because it doesn't support FillPath/DrawPath, but maybe sometime I will do something on it and then it would be bad, if I couldn't easily provide it to the community. It is a really great project!
hello~everyone~~ i am just beginning to learn SVG... just as title... i downloaded the source file,but i don't know how to install the source file... could you tell me how to do? thanks ~!!!
Hello. We are som students trying to use SvgNet in asp.net to generate a svg picture´.. But it isnt working. we are using an Embed tag inside the asp.net page like this:
im new to learning svg. i open the project svgdoctest. im trying to run the SvgDocTest but compiler is giving many errors. ive already installed adobe svg viewer. below are the errors given:-
a) line 0 = missing file specification for 'lr' command-line option(CS2005) b) line 33,34,35 = the type/namespace name 'SvgNet' could not be found(are you missing directive or an assembly reference?)(CS0246) c) line 50,51 = the type/namespace name 'AxSVGACTIVEXLib' could not be found (are you missing directive or an assembly reference?)(CS0246) d) line 220 = the type/namespace name 'SvgElement' could not be found (are you missing directive or an assembly reference?)(CS0246) e) line 67 = TODO Add any constuctor code after InitializeComponent call
please help me solve this as im doing a project regarding svgnet.
Hello. im nab from japan. I sorry my english is poor. i hope u can understand.
i love svgnet and using it.but... i have a question about how to use svgnet.
i want to make SVG file. like this. -------------------------------------------------------------
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
-------------------------------------------------------------- this file has two svg tag. is it possible to make this SVG File in SVGnet? please help me.
how should I write the code? ------------------------------------------- SvgGraphics ig; ig = new SvgGraphics(); ig.FillRectangle(new SolidBrush(Color.Red),8,8,100,200); //---how should i write a code? i wanna insert svgtag more in SVGFile-- xxx.FillRectangle(new SolidBrush(Color.Blue),8,8,50,100); //---- string s = ig.WriteSVGString(); StreamWriter tw = new StreamWriter("c:\\temp\\foo.svg", false); tw.Write(s); tw.Close(); svgCtl.SRC = "c:\\temp\\foo.svg"; -------------------------------------------
plz help me again. thank u for reading my english. u know my English is too poor.