Tuesday 22 May 2018

Convert Fusion chart SVG to Png,jpg using jquery in asp.net c#

//////////////////////////////////////////////// Fusion fusion chart js

Step 1.  Generate fusion chart





Step 2.  Set a Java-script  function for converting the  SVG data into 64byte image file. and set this value into the hidden field variable.

<script type="text/javascript">
        function Convert_Svg_Png() {
            if (!$('#mDmyChartar2_div').length) {
                var svgString = $('#myChartar2_div span').html();
                var canvas = document.createElement('canvas');
                var DOMURL = self.URL || self.webkitURL || self;
                var img = new Image();
                var svg = new Blob([svgString], { type: 'image/svg+xml;charset=utf-8' });
                var url = DOMURL.createObjectURL(svg);
                img.onload = function () {
                    canvas.width = img.width; canvas.height = img.height; canvas.getContext('2d').drawImage(img, 0, 0);
                    var png = canvas.toDataURL('image/png');
                    var div = document.createElement('div'); $(div).attr('id', 'mDmyChartar2_div');
                    $(div).html('<img id="img_myChartar2_div" src="' + png + '" />'); $(div).css('display', 'none');
                    $('#myChartar2_div').append(div); DOMURL.revokeObjectURL(png);
                }; img.src = url;
            }
        }
    </script>








Setp 3. Convert 64byte image into png file and save server folder


var p = System.Text.Encoding.UTF8.GetBytes(64byteImgData);
string p1 = Encoding.UTF8.GetString(p);

byte[] bytes = Convert.FromBase64String(p1);
System.Drawing.Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = System.Drawing.Image.FromStream(ms);
}


string FilePath = Server.MapPath("~/Charts/" + FileName + i + ".jpg");
image.Save(FilePath);

Setp 4.  Now You can any thing with this image








6 comments:

  1. It could help me make the most of my nourishment and time alone. Eating carefully may help me know about sound nourishment and acknowledging sustenance. png to svg

    ReplyDelete
  2. Your enthusiasm leads you beyond the limits. whilst you feel yourself enthusiastic that’s the time you can pass any restrict. you're searching out to get perfection through the usage of the functionality of exertions. study such motivational article and truely it'll permit you to recognize new data. png to svg

    ReplyDelete
  3. Consummate case of hypothesis, compassion and expression. Here I took in another approach to theorize through writer's written work. It enabled me to feel another approach to estimate your considerations and express them in a simple and clear way. Image Vectorizer Mac

    ReplyDelete
  4. Super Vectorizer automatically converts PNG files to SVG graphics on Mac and make the svg results easier to edit and adjust. Image Vector Mac

    ReplyDelete
  5. At some point couple of instructive online journals turn out to be extremely useful while getting pertinent and new data identified with your focused on zone. As I discovered this blog and value the data conveyed to my database. png to svg

    ReplyDelete
  6. Super Vectorizer automatically converts PNG files to SVG graphics on Mac and make the svg results easier to edit and adjust. Image Vectorizer Mac

    ReplyDelete

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...