【发布时间】:2015-02-26 21:36:17
【问题描述】:
我正在尝试使用 c# 在我的 asp.net 应用程序中将 svg 转换为 png。我从here 那里得到了一些帮助。我听从了 Anish 的建议。但我对此有所例外。我不知道这个。我的代码包括:
string path = "d:\\";
string svgstr = temp.Value;
var byteArray = Encoding.ASCII.GetBytes(svgstr);
var stream = new MemoryStream(byteArray);
var bitmap = SvgDocument.Open(stream).Draw();
bitmap.Save(path, ImageFormat.Png);
我收到以下异常:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 102: var stream = new MemoryStream(byteArray);
Line 103:
Line 104: var bitmap = SvgDocument.Open(stream).Draw();
Line 105:
Line 106: bitmap.Save(path, ImageFormat.Png);
Source File: e:\HighchartDemo\HighchartDemo\ColumnChart.aspx.cs Line: 104
我真的需要这方面的帮助。任何其他替代方式也会有所帮助。谢谢大家
【问题讨论】:
标签: javascript c# svg