Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Images not showing in exported .bmp or .pdf files (Read 3427 times)
MattKay
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Jul 2nd, 2013
Images not showing in exported .bmp or .pdf files
Jul 2nd, 2013 at 5:47pm
Print Post  
Hello all,

I am using the trial version of ASP.NET MVC Diagramming (our team will definitely be buying at least one license if we can get this issue resolved), and have ran into an issue with the images not showing when I try to export to .bmp or .png. It instead shows the ShapeNode (which should be transparent) on the exported file with no image in the Shape. Here is the code I am using:

Code
Select All
ShapeNode imageNode = diagram.Factory.CreateShapeNode(new RectangleF(0, 0, 60, 20));
                imageNode.Shape = myShape;
                String path1 = Server.MapPath("./Resources/IS-logo-global.png");
                Image img1 = Image.FromFile(path1);
                imageNode.Image = img1;
                imageNode.ImageUrl = "/WorkflowDemo/Resources/IS-logo-global.png";
                imageNode.Brush = new MindFusion.Drawing.SolidBrush(Color.Transparent);
                imageNode.Pen = new MindFusion.Drawing.Pen(Color.Transparent); 



I have read several posts with issues about not being able to show an image correctly and have tried all of the recommended solutions to no avail. Can anyone help me out with this issue?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Images not showing in exported .bmp or .pdf files
Reply #1 - Jul 2nd, 2013 at 6:18pm
Print Post  
Hi,

Images are one area where our JavaScript diagramming library and server controls are not very well integrated yet. If you set the Image property on the server side, its value will be lost after a round-trip to the client. Only ImageUrl is sent to the client and loaded into JavaScript Image objects.

At this time you will have to loop over all nodes  just before exporting, and explicitly load their server-side image file from the nodes' ImageUrl. I.e. try doing something like this, adding or removing some part of the file paths if necessary:

Code
Select All
foreach (ShapeNode node in diagram.Nodes)
  node.Image = Image.FromFile(Server.MapPath(node.ImageUrl));
pdfExporter.Export(...); 



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


I Love MindFusion!

Posts: 2
Joined: Jul 2nd, 2013
Re: Images not showing in exported .bmp or .pdf files
Reply #2 - Jul 2nd, 2013 at 7:27pm
Print Post  
Stoyo wrote on Jul 2nd, 2013 at 6:18pm:
Hi,

Images are one area where our JavaScript diagramming library and server controls are not very well integrated yet. If you set the Image property on the server side, its value will be lost after a round-trip to the client. Only ImageUrl is sent to the client and loaded into JavaScript Image objects.

At this time you will have to loop over all nodes just before exporting, and explicitly load their server-side image file from the nodes' ImageUrl. I.e. try doing something like this, adding or removing some part of the file paths if necessary:

Code
Select All
foreach (ShapeNode node in diagram.Nodes)
  node.Image = Image.FromFile(Server.MapPath(node.ImageUrl));
pdfExporter.Export(...); 



I hope that helps,
Stoyan


Great, thanks for the response! I was hoping that there was something built in currently but this works perfectly. Out of curiosity, are you guys still adding features to ASP.NET MVC Diagramming?

By the way, just in case anyone else has this issue and sees this post, here was the final solution for me:

Code
Select All
foreach (ShapeNode node in diagram.Nodes)
            {
                if(node.ImageUrl != ""){
                    String imgPath = Server.MapPath(node.ImageUrl);
                    node.Image = Image.FromFile(imgPath);
                }

            }
            pdf.Export(diagram, path); 



The if-statement is required for any nodes that do not have a value set for the ImageUrl (which seems to default to an empty String).
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Images not showing in exported .bmp or .pdf files
Reply #3 - Jul 3rd, 2013 at 6:48am
Print Post  
Quote:
Out of curiosity, are you guys still adding features to ASP.NET MVC Diagramming?


Yes, we are - mostly porting features from our desktop components at this time. If there's something specific you'd like to see in the library, you could post feature suggestions here and our developers will have them in mind for next releases:
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_feat

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint