Save diagram image in database

Hi 

We need to save diagram image in the database that can be shown in SSRS report. only I can find is export to image on the client side. how we can get an image in png format from the server side to save it on the database.

Thanks
Charaka

1 Reply

SG Shyam G Syncfusion Team January 8, 2018 10:04 AM UTC

Hi Charaka, 

When we set the mode as data in the diagram client side API exportDiagram method, it returns base64data and you can send that data to the server side from the client side using AJAX. In the server side, you can generate an image from that data and you can save that base64data to an database. Please refer to the code example and help documentation below. 
 
Code example: 
function save() { 
            var diagram = $("#Diagram2").ejDiagram("instance"); 
            //get the base64data 
            var image = diagram.exportDiagram({ mode: "data"}); 
            $.ajax({ 
                type: "POST", 
                contentType: "application/json; charset=utf-8", 
                url: "Data.aspx/save", 
                dataType: "json", 
                data: "{'base64data': '" + image + "'}", 
                success: function (Jsonstring) { 
                    alert("Success"); 
                    return true; 
                }, 
            }); 
        } 
 
[WebMethod] 
        public static void save(string base64data) 
        { 
            //get the base64data and save it to database 
            string image = base64data; 
            //Do the code to process it as an image 
        } 

 
Regards, 
Shyam G 


Loader.
Up arrow icon