Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Save/Export Diagram as .gif or .jpg Image (Read 7628 times)
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Save/Export Diagram as .gif or .jpg Image
Feb 18th, 2009 at 8:48pm
Print Post  
I'm using the sample C# Flowcharter application for VS2005. Is there a way to save or export the diagram as a .gif or .jpg image to display in an HTML report on the website or in a Word (or any other) document. I know you can export to PDF, but I need an image.

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save/Export Diagram as .gif or .jpg Image
Reply #1 - Feb 18th, 2009 at 9:15pm
Print Post  
Diagram.CreateImage returns a Bitmap object. Then call Bitmap.Save - it support GIF, JPEG and several other formats. You might also check the HtmlBuilder class.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #2 - Feb 18th, 2009 at 9:27pm
Print Post  
That does the trick. Thanks!
  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #3 - Feb 19th, 2009 at 1:29pm
Print Post  
I'm having a couple problems when saving the diagram as an image:

1. I can add text to the shapes on the diagram and size them to fit perfectly, but when I create the bitmap image, the text can get cutoff and line breaks get out of place.

2. I inserted an image into one of my custom shapes, but when I create a bitmap of a diagram containing that shape, the image doesn't show up on the shape in the bitmap.

Any ideas?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save/Export Diagram as .gif or .jpg Image
Reply #4 - Feb 19th, 2009 at 1:41pm
Print Post  
1. If you are using JavaApplet mode, this might happen because of slight differences in the Java and .NET font measure and rendering functions. You could get an image exactly matching what's show in the applet by calling Diagram.createImage on the client side, so it is rendered using the Java API.

Now transferring that image to the server to save it as a file will be a bit harder; for example, you could assign it to a temporary node by calling node.setImage(), the applet will serialize the image upon postback and load it on the server, where you can finally call tempNode.Image.Save() to export it to a file.

2. You have set the Image of a custom Shape definition, or the ShapeNode's Image?

Stoyan
  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #5 - Feb 19th, 2009 at 1:46pm
Print Post  
1. I'll try and figure that out and let you know how it works.

2. Using the Shape Designer tool, I created a custom image (a box), and used the File menu to insert an image onto the shape. I use that shape in a diagram and see the image fine, but when I create a bitmap from that diagram, the images doesn't appear on the shape. It appears to be replaced with some text, but I can't make it out. Maybe it's an error message or something.

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save/Export Diagram as .gif or .jpg Image
Reply #6 - Feb 19th, 2009 at 1:53pm
Print Post  
What is the src value for the <image> in the shape library file?
  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #7 - Feb 19th, 2009 at 1:57pm
Print Post  
Currently, it is just relative to the shape file and looks like this: src="image.jpg"

I tried changing it to an absolute path like this: src="http://127.0.0.1/flowcharter/shapes/image.jpg"

Same result either way. I wonder if creating the image on the client side will take care of this, too?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save/Export Diagram as .gif or .jpg Image
Reply #8 - Feb 19th, 2009 at 2:07pm
Print Post  
Are the .shl and .jpg files are in the same folder? It seems ShapeLibrary.LoadFrom() fails to find the image when loading shapes locally on the server side, even if in theory it supports relative paths. As a quick workaround, you could load the image immediately after ShapeLibrary.LoadFrom, e.g. Shape.FromId(...).Image = Image.FromFile(localPath);

Stoyan
  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #9 - Feb 19th, 2009 at 2:17pm
Print Post  
That works, but like you said, for a quick workaround. It makes the code less generic. If I had to, I suppose I could just parse the shape file library on page load and use Shape.FromID(...).Image=Image.FromFile(localPath) whenever I encounter the image tag and src attribute.

Thanks for your help!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save/Export Diagram as .gif or .jpg Image
Reply #10 - Feb 19th, 2009 at 2:22pm
Print Post  
Are you calling ShapeLibrary.LoadFrom() with the full path to the .shl file as argument?
  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #11 - Feb 19th, 2009 at 2:27pm
Print Post  
I'm using a full URL: ShapeLibrary.LoadFrom("http://127.0.0.1/flowcharter/shapes/shapes.xml");
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save/Export Diagram as .gif or .jpg Image
Reply #12 - Feb 19th, 2009 at 2:32pm
Print Post  
I didn't know LoadFrom could work with an URL argument Smiley Could you check if passing a local file system path makes the images load ok?

Stoyan
  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #13 - Feb 19th, 2009 at 2:43pm
Print Post  
No, I tried local file system path when I first started and couldn't get that to work. I found somewhere on this discussion forum that you had to use an accessible URL and that is the only way I can get it to work - unless I'm missing something.

  
Back to top
 
IP Logged
 
mws0717
YaBB Newbies
*
Offline



Posts: 13
Joined: Feb 17th, 2009
Re: Save/Export Diagram as .gif or .jpg Image
Reply #14 - Feb 19th, 2009 at 2:45pm
Print Post  
I may have that confused with ShapeList.ShapeLibraryLocation.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint