Sending Diagram to server

1 Answer 23 Views
Diagram
John
Top achievements
Rank 1
Veteran
John asked on 18 Mar 2022, 01:54 PM

In our project we have a web page that produces a diagram on screen; we would like to take this diagram and place it in a report. The report is generated on our server and the diagram is obviously shown in the browser on the client computer.

My question is, is there a way of taking the current view and sending it to the server and may be storing it in the database as a BLOB image? If I can do this then I will be able to insert the image in to the reports I generate/build.

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 23 Mar 2022, 08:19 AM

Hello, John,

You can export the Diagram to several different formats, including an image. The approach is showcased in the advanced export demo:

        $(".export-img").click(function() {
            var diagram = $("#diagram").getKendoDiagram();
            diagram.exportImage().done(function(data) {
                kendo.saveAs({
                    dataURI: data,
                    fileName: "diagram.png",
                    proxyURL: "https://demos.telerik.com/kendo-ui/service/export"
                });
            });
        });

Instead of saving the image, you can send the data over to the server for later usage. After that you can use the base64 string(the data) to render the image wherever you need it. For example if we are talking about the web, you can use the following approach to convert base64 to an image and append it to the body of the page:

              let image = new Image();
              image.src = data;
              $("body").append(image);

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Diagram
Asked by
John
Top achievements
Rank 1
Veteran
Answers by
Georgi Denchev
Telerik team
Share this question
or