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. Image for the cookie policy date

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

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


7 Replies

SG Shyam G Syncfusion Team 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. 

Regards, 
Shyam G 



JJ Jim Jacobs 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.

Jim



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



JJ Jim Jacobs October 24, 2016 12:24 PM UTC

Hi Shyam,

This is perfect and simpler than where I was headed.

Thanks

Jim


SG Shyam G Syncfusion Team October 25, 2016 03:36 AM UTC

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



JJ Jim Jacobs 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.

Jim


SG Shyam G Syncfusion Team 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.  

Regards, 
Shyam G 


Loader.
Live Chat Icon For mobile
Up arrow icon