Thursday, December 5, 2013

Read SVG Data into C# , Dotnet Graphics

Below is an easy way to convert an SVG path tag into a C# System.Drawing.Drawing2D.GraphicsPath.


This SVG project provides a solution in the following way:
var pathData = ...;

var graphicsPath = new GraphicsPath();

foreach (var segment in SvgPathBuilder.Parse(pathData))
    segment.AddToPath(graphicsPath);

graphics.DrawPath(Pens.Black, graphicsPath);
It's available as a NuGet package via:
PM> Install-Package Svg

http://stackoverflow.com/questions/5711503/converting-svg-path-data-into-gdi-graphicspath-data