Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing SVG in .NET/C#? [closed]

I'd like to generate an SVG file using C#. I already have code to draw them in PNG and EMF formats (using framework's standard class System.Drawing.Imaging.Metafile and ZedGraph). What could you recommend to do to adapt that code to SVG? Preferably I'd like to find some library (free or not) that would mimic System.Drawing.Graphics interface.

like image 811
liori Avatar asked Oct 06 '09 12:10

liori


People also ask

What is SVG in C#?

Scalable Vector Graphics (SVG) is an XML-based vector image format.

Does Visual Studio support SVG?

SVG is XML and fortunately, Visual Studio and Visual Web Developer come with XML editor that provides intellisense and validation provided you have appropriate XML schema. Although XML editor supports both DTD and XSD validation we decided to use XSD schema. W3C site provides only modularized DTD schema for SVG.

Can SVGs be printed?

You can use SVG files for some print work, particularly printing for clothing and crafting —but they're not compatible with enough devices to rely on them for day-to-day tasks.


2 Answers

Check out the SVG framework in C# and an SVG-GDI+ bridge project.

From the above web page...

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.

like image 150
Autodidact Avatar answered Sep 18 '22 13:09

Autodidact


We have made a public fork of the C# .NET SVG library on Github.

It is much improved over the one you find on Codeplex, please have a look and fork it as you like:

https://github.com/svg-net/SVG

Edit: Just to let you know, as of January 2021:

While others seem dead for years, this is still active. But we could definitely use some help from other developers.

like image 45
thalm Avatar answered Sep 20 '22 13:09

thalm