Skip to content

Instantly share code, notes, and snippets.

@ry8806
Created February 11, 2016 19:14
Show Gist options
  • Select an option

  • Save ry8806/fcd7dfcb3b2552d140fc to your computer and use it in GitHub Desktop.

Select an option

Save ry8806/fcd7dfcb3b2552d140fc to your computer and use it in GitHub Desktop.
C# server-side rendering with Highcharts
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