I\'m trying to convert my svg to an image I\'ve been looking into several tools and still can\'t make this happen :(
1. SVG rendering engine but I\'
Your SVG loads in Chrome and Renders.
I've downloaded your SVG and the DLL from CodePlex, and recreated your simple two line fail with your SVG in LinqPad4.
I get the same fail, but LinqPad4 shows the DLLs Trace output and it shows
...
LINQPad.exe Information: 0 : Begin CreateElement: rect
LINQPad.exe Information: 0 : Begin SetAttributes
LINQPad.exe Information: 0 : End SetAttributes
LINQPad.exe Information: 0 : End CreateElement
LINQPad.exe Information: 0 : End Read
loaded -- I added this to show the different method calls
LINQPad.exe Information: 0 : Begin Render
...
StackTrace at Svg.SvgUnit.ToDeviceValue(ISvgStylable styleOwner, Boolean vertical)
at Svg.SvgRectangle.get_Path()
at Svg.SvgGraphicsElement.Render(SvgRenderer renderer)
at Svg.SvgRectangle.Render(SvgRenderer renderer)
at Svg.SvgElement.RenderChildren(SvgRenderer renderer)
at Svg.SvgElement.Render(SvgRenderer renderer)
at Svg.SvgDocument.Draw()
HelpLink null
So something is going wrong when it tries to draw the first path.
You say there is no documentation, yet the Whole Source code including project files etc is there on CodePlex. You could download it and see if you can fix the issue in the Svg.SvgUnit.ToDeviceValue method...
...or just download ImageMagick and use the Process class to trigger the command line program Convert.exe
I made a couple of changes to you code here: I think InkScape was having a problem with you paths, you'd used
PngRelativeDirectory + "\" + pngFileName
PngRelativeDirectory already had a "\" in it so the path was coming our as c:\\sample.png
Also i changed the Context.RewritePath to Response.Redirect - I get the pie chart rendered in the browser the browser.
string svgFileName = HttpContext.Current.Server.MapPath("sample.svg");
string PngRelativeDirectory = "C:\\";
string pngName = "svgpieresult.png";
string pngFileName = HttpContext.Current.Server.MapPath(pngName);
/* ignored assume sample.svg is in the web app directory
using (StreamWriter writer = new StreamWriter(svgFileName, false))
{
writer.Write(svgXml);
}
*/
string inkscapeArgs = string.Format(@"-f ""{0}"" -e ""{1}""", svgFileName, pngFileName);
Process inkscape = Process.Start(
new ProcessStartInfo( "C:\\Program Files\\inkscape\\inkscape.exe", inkscapeArgs));
inkscape.WaitForExit(3000);
//Context.RewritePath(pngName);
this.Response.Redirect(pngName);