How to convert a saved diagram to svg in code behind (no UI)

Hi,

I am saving my diagrams in a database.
I now have a need to use these diagrams elsewhere in my application.
So I need to read the saved diagram data and convert it to svg format.
Later I'll also need to convert the diagram data to an image format such as png.

I was hoping to use something like the following:

public String GetActivityDiagramImage(String activityID)
    {
        String diagram_Data = GetDiagram(activityID);
        Diagram diagram = new Diagram();

        JavaScriptSerializer js = new JavaScriptSerializer();
        string JSON = js.Serialize(diagram_Data);

        //diagram.load(JSON);
        //diagram.saveAsSVG...

        return "Diagarm in SVG Format";
    }

But there is no load method in code behind.

Any suggestions on how to accomplish what I'm trying to do?

Thanks

Jim

7 Replies

SG Shyam G Syncfusion Team January 12, 2015 04:46 PM UTC

Hi Jim

Thanks for using Syncfusion products.

Currently we don’t have the support to load the diagram in the server side. We consider this as a feature request and created a new incident 133908 on behalf of you related to this forum. We suggest you to follow up the incident for further reference using your direct trac account. However we have created a workaround sample to load the diagram in the server side.

Sample:http://www.syncfusion.com/downloads/support/directtrac/117935/loadinserverside521806239.zip

Code snippet to export SVG in server side:

function exportassvg() {

            PageMethods.exportassvg();

        }

[WebMethod]

        public static void exportassvg()

        {

            //you can perform export to svg here

        }

Please let me know if any concerns.

Regards,

Shyam G




SK Sarantis Kosmas June 4, 2024 04:59 PM UTC

Good day,


I know this thread is really old, but it is the only one that is relevant to my situation. Is there any resources that you can point me to for an example on how to generate a diagram from json server side. Specifically in a .net web application? 


Unfortunately it seems I do not have access to the issue link above and the link to the zip file has an authorization issue.


Kind regards,

Robert



VG Vivisa Ganesan Syncfusion Team June 5, 2024 01:27 PM UTC

Hi,

As mentioned earlier, we currently don’t have support to load the diagram on the server side; our support is limited to the UI level. Could you please share the details of your exact requirements so that we can validate them and provide you with more information?


Regards,

Vivisa



SK Sarantis Kosmas June 6, 2024 08:41 AM UTC

Hi,


To keep it simple, we have a system that provides an organization tree structure. On each node of the structure it is possible to create diagrams. The diagrams are created on the front-end and stored as json in a database. We are busy implementing export functionality, to export all node data related to the specific organization, which obviously includes diagrams. For the client, it does not help to save the json as they have no way of viewing the original diagram.


Thus, we need to render/generate the diagram server side in order to export a svg/pdf or any other format which enables the client to view the diagram if they wish to do so.


Hope this explanation helps.


Kind regards,

Robert



VG Vivisa Ganesan Syncfusion Team June 7, 2024 07:03 AM UTC

Hi,

                          Query

                        Solution

To keep it simple, we have a system that provides an organization tree structure. On each node of the structure it is possible to create diagrams. The diagrams are created on the front-end and stored as json in a database. We are busy implementing export functionality, to export all node data related to the specific organization, which obviously includes diagrams. For the client, it does not help to save the json as they have no way of viewing the original diagram.

 

 

We provide support for loading a saved JSON in the client using the `loadDiagram` method. Refer to the User Guide below for more information:

UG:

 

https://ej2.syncfusion.com/aspnetcore/documentation/diagram/serialization

 

Thus, we need to render/generate the diagram server side in order to export a svg/pdf or any other format which enables the client to view the diagram if they wish to do so.

 

We support exporting diagrams as SVG and generating PDFs on the client side. Refer to the UG below for instructions on exporting as SVG, and watch the accompanying video to learn how to export as PDF using the diagram print method.

 

UG

https://ej2.syncfusion.com/aspnetcore/documentation/diagram/export#format

 

 

Sample:

https://stackblitz.com/edit/vajmls-2kj2y5?file=index.html,index.js

 



Regards,

Vivisa



Attachment: Save_as_PDF_66e06b77.zip


SK Sarantis Kosmas June 7, 2024 02:43 PM UTC

Hi,


Thank you for the response.


Kind regards,

Robert 



VG Vivisa Ganesan Syncfusion Team June 10, 2024 04:44 AM UTC

Hi,

You're welcome! Please let us know if you have any further queries on this. We will be happy to assist.


Regards,

Vivisa


Loader.
Up arrow icon