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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

126979 Oct 19,2016 09:30 AM Nov 4,2016 10:52 AM ASP.NET Web Forms 7
loading
Tags: Diagram
Jim Jacobs
Asked On October 19, 2016 09:30 AM

Hi,

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?

Thanks

Jim


Shyam G [Syncfusion]
Replied On October 20, 2016 08:43 AM

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. 

Regards, 
Shyam G 


Jim Jacobs
Replied On October 20, 2016 12:06 PM

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.

Jim


Shyam G [Syncfusion]
Replied On October 21, 2016 08:31 AM

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"); 
 
 
Regards, 
Shyam G 


Jim Jacobs
Replied On October 24, 2016 08:24 AM

Hi Shyam,

This is perfect and simpler than where I was headed.

Thanks

Jim

Shyam G [Syncfusion]
Replied On October 24, 2016 11:36 PM

Hi Jim, 
Thanks for your update. 
Regards, 
Shyam G 


Jim Jacobs
Replied On November 3, 2016 11:40 AM

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.

Jim

Shyam G [Syncfusion]
Replied On November 4, 2016 10:52 AM

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.  

Regards, 
Shyam G 


CONFIRMATION

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.

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.

;