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.
Scalable Vector Graphics (SVG) is an XML-based vector image format.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With