We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load, modify and save a diagram in batch (no actual display of the diagram)

Thread ID:





126979 Oct 19,2016 01:30 PM UTC Nov 4,2016 02:52 PM UTC ASP.NET Web Forms 7
Tags: Diagram
Jim Jacobs
Asked On October 19, 2016 01:30 PM UTC


Currently when we save a diagram, we save 2 things in our database:
  1. The JSON data
  2. A png image of the diagram

We have several export utilities that rely on these saved png images.

The issue: we need to change ALL of our diagrams (removing the page border), but the only way at the moment seems to be to load the diagram (at which time we'll remove the border) and then when the user saves the diagram we can save a new png file with this change.

This requires all of our users to open all of their diagrams, make some subtle change and save them.

Not an acceptable solution - we have close to 25,000 diagrams.

So, is there a way to accomplish this using some batch capability.

I have written and tested a utility to update the JSON data in the database - that's not the challenge.

It's getting an updated png image that's the real problem.

Any suggestions on an approach?



Shyam G [Syncfusion]
Replied On October 20, 2016 12:43 PM UTC

Hi Jim, 

Please confirm us whether you need an utility to get an image from the database and remove the page Border from the image and update the same into the database. If yes, we will analyse and provide a better solution. If we misunderstood your requirement, please provide us more details such as elaborate your requirement in detail with the screenshot. 

Shyam G 

Jim Jacobs
Replied On October 20, 2016 04:06 PM UTC

Hi Shyam,

Yes, that's exactly what we want to do - remove the border from the png images saved in our database.
The border was created through the following properties set in code behind:
  •         DiagramContent.PageSettings.PageBorderColor = "blue";
  •         DiagramContent.PageSettings.PageBorderWidth = 2;

We have since change the border width to 0, but need to update all existing png images.

Thanks for pursuing a solution for us.


Shyam G [Syncfusion]
Replied On October 21, 2016 12:31 PM UTC

Hi Jim, 
We have created a sample in which we have get the image from the saved folder location and cropped that image and again saved it to that folder location. By the same way, you can get the image from the database and crop that image and save back to the database. Please refer to the code example below. 
Code example: 
//specify the width and height values which you are going to crop from the image 
            Rectangle CropRect = new Rectangle(0,0,400,400); 
            //specify the image location or image name 
            Bitmap src = Image.FromFile("c://users/shyamg/documents/visual studio 2013/Projects/WindowsFormsApplication1/WindowsFormsApplication1/borderimage.PNG") as Bitmap; 
            Bitmap target = new Bitmap(CropRect.Width, CropRect.Height); 
            using (Graphics g = Graphics.FromImage(target)) 
                //draw an image  
                g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), CropRect, GraphicsUnit.Pixel); 
            //save to the location 
            target.Save("c://users/shyamg/documents/visual studio 2013/Projects/WindowsFormsApplication1/WindowsFormsApplication1/diag.PNG"); 
Shyam G 

Jim Jacobs
Replied On October 24, 2016 12:24 PM UTC

Hi Shyam,

This is perfect and simpler than where I was headed.



Shyam G [Syncfusion]
Replied On October 25, 2016 03:36 AM UTC

Hi Jim, 
Thanks for your update. 
Shyam G 

Jim Jacobs
Replied On November 3, 2016 03:40 PM UTC

Hi Shyam,

I have a somewhat related requirement, and since it's so close to this thread's subject, I thought I'd just add it here.

Here's the situation.
There are some values that can be changed in our application outside of the diagram page.
For example, the user can change a role (function) name (e.g., from Process Mgr. to Process Manager).
When the diagram is displayed, I check to see if a role name has changed and if so, I update the appropriate lane header text.
So far so good.
Also, when the diagram is saved, I also save a png image of the diagram at the same time.

We have a Word document that is produced that includes these saved images.
But unless the user opens the diagram(s), there is no save done and hence the images are out of sync with any role name changes.

Can you see any approach to updating a diagram and saving it (and a png image) without actually opening/loading the diagram?
I know I can update the JSON data in the database directly, but the real requirement is to get an updated png image.

I hope our requirement is clear.  As you can see, it's not quite as simple as removing the border.

Thanks for any advice.


Shyam G [Syncfusion]
Replied On November 4, 2016 02:52 PM UTC

Hi Jim, 

Could you please confirm us whether you are modifying the JSON data outside the diagram scope and updating it in the database and also you need to do the same procedure for the image. If yes, we could not update the image without rendering the diagram. you need to render the diagram and export it as an image format.  

Shyam G 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon