Thursday, 31 October 2013

Convert SVG to PNG using svg.dll

      <div id="divsvg">

       <svg width="350" height="300"><defs></defs> ................</svg>

        </div>

<script type="text/javascript">

        var svg = $('#divsvg').html();

        document.getElementById("<%= hfdata.ClientID %>").value = encodeURIComponent(svg);

</script>

Code behind:

            var svg = hfdata.Value;

            var urldec = System.Web.HttpUtility.UrlDecode(svg);

             var svgpath = Server.MapPath("~") + "temp\\" + sessionid + ".svg";

            File.WriteAllText(svgpath, urldec);

            var sampleDoc = SvgDocument.Open(svgpath);

            sampleDoc.Draw().Save(Server.MapPath("~") + "\\App_Data\\tempImages\\" + sessionid + ".png");

No comments:

Post a Comment

Convert SVG to PNG using svg.dll

      <div id="divsvg">        <svg width="350" height="300"><defs></defs> ............