Converting SVG to PNG using C#


I've been trying to convert SVG images to PNG using C#, without having to write too much code. Can anyone recommend a library or example code for doing this?

9/20/2008 10:22:45 AM

Accepted Answer

You can call the command-line version of inkscape to do this:

Also there is a C# SVG rendering engine, primarily designed to allow SVG files to be used on the web on codeplex that might suit your needs if that is your problem:

Original Project

Fork with fixes and more activity: (added 7/2013)

11/13/2013 10:59:58 AM

There is a much easier way using the library (Newer version @GIT, @NuGet). Here is my code

var byteArray = Encoding.ASCII.GetBytes(svgFileContents);
using (var stream = new MemoryStream(byteArray))
    var svgDocument = SvgDocument.Open(stream);
    var bitmap = svgDocument.Draw();
    bitmap.Save(path, ImageFormat.Png);

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow