Created
February 11, 2016 19:14
-
-
Save ry8806/fcd7dfcb3b2552d140fc to your computer and use it in GitHub Desktop.
C# server-side rendering with Highcharts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Svg; | |
| using System.Drawing; | |
| using System.Drawing.Imaging; | |
| using System.IO; | |
| namespace SvgRenderer | |
| { | |
| public class Renderer | |
| { | |
| public void Render(string svg) | |
| { | |
| SvgDocument svgDoc = SvgDocument.FromSvg<SvgDocument>(svg); | |
| // Or even get this from a Stream | |
| //SvgDocument svgDoc = SvgDocument.Open<SvgDocument>(stream); | |
| // Save to the disk | |
| Bitmap image = svgDoc.Draw(); | |
| image.Save(@"C:\temp\mySvg.png", ImageFormat.Png); | |
| // Or save to a Stream (to return in a WebApi for example) | |
| //MemoryStream ms = new MemoryStream(); | |
| //image.Save(ms, ImageFormat.Png); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment