C#을 사용하여 내 asp.net applictaion에서 sng를 png로 변환하려고합니다. here에서 도움을 받았습니다. 나는 Anish의 제안을 따랐다. 하지만 이것에 대한 예외가 생깁니다. 나는 이것에 대해 생각하지 못한다. 내 코드는 다음과 같습니다SVG 렌더링 엔진을 사용하여 svg를 png로 변환 할 때 예외가 발생했습니다.
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
난 정말이에 도움이 필요합니다. 다른 대안적인 방법이 도움이 될 것입니다. 고마워요.
svg에서 이미 차트 작업을 완료했습니다. 이제 저는 그것이 수출을 위해 이미지로 변환되기를 바랍니다. –
phantom.js를 사용하여 이미지를 만들고 서버에 저장 한 다음 거기에서 내보낼 수 있습니다. Phantom.js는 하이 차트의 서버 쪽 이미지를 만드는 데 사용됩니다. 다음은 http://www.highcharts.com/component/content/article/2-articles/news/56-improved-image-export-with-phantomjs에 대한 링크입니다. –