This project is read-only.

In memory SVG to image conversion?

Mar 16, 2011 at 1:56 AM

Is it currently possible to give the library a string containing valid XML / SVG data, then convert it to an image format, like a PNG or JPEG, all in memory?

For example (pseudo code):

using (var stream = new MemoryStream())
    string svgText = "data here";
    var sampleDoc = SvgDocument.OpenFromMemoryStream(stream);
    var Image = sampleDoc.Draw().ToPng();

If it's not possible, are there any plans to support this functionality? I ask because we're receiving data from a user, and i hesitate to write user generated data to the file system. Sure, I can write it to a local directory of my project, like ~/Content/Volatile or something, but I'd prefer to use a memory stream that can be garbage collected as soon as the conversion is done.

Mar 17, 2011 at 4:35 AM

Yes, it is possible. There is an SvgDocument.Open overload that accepts a Stream object, so the MemoryStream should work just fine.