Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Exporting to Image & PDF (Read 3788 times)
Mark M.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Apr 12th, 2013
Exporting to Image & PDF
Apr 22nd, 2013 at 8:14am
Print Post  
Dear Stoyo,

       What would be the recommended approach to let the user export the diagram as an image or as a PDF. We would prefer prompting user with a save dialog box.

        Should we send back client side diagram data as JSON to server? In that case, could you show us a few sample codes?

         Or should we use diagram.SaveToString(SaveToStringFormat.Base64,true) at serverside, store in hidden field and send it back when user clicks export? In that case, we loses the option to export as pdf right? We tried this one anyway and base64 string it gave could not be decoded back both at the client and server.

         Please advise. Thanks in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exporting to Image & PDF
Reply #1 - Apr 22nd, 2013 at 9:52am
Print Post  
Hi,

Check the PdfExporter sample project. Modify the export handler to return a File action if you want to show a save as dialog:

Code
Select All
var pdf = new MindFusion.Diagramming.Export.PdfExporter();
string path = Server.MapPath(@"~\PDF\") + Session.SessionID + ".pdf";
pdf.Export(diagram, path);
return File(path, "application/pdf", "diagram.pdf"); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Mark M.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Apr 12th, 2013
Re: Exporting to Image & PDF
Reply #2 - Apr 22nd, 2013 at 10:46am
Print Post  
Dear Stoyo,

       It's probably a stupid question. In the PdfExport sample, it uses "diagramView1_PostData" hidden field to transfer generated diagram data back to the server side as Json. We are using MVC 4 Razor and we attempted to capture the same hidden field since the field did exist similar to the sample. However, it always seemed to be empty. Could you provide us with a way to get diagram reference back so that we can use PdfExporter to generate Pdf?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exporting to Image & PDF
Reply #3 - Apr 22nd, 2013 at 2:03pm
Print Post  
Here our developer ported PdfExporter with Save As addition to MVC4 / Razor, we can't see any problems loading the posted diagram:
https://mindfusion.eu/_samples/PdfExporter_Mvc.zip

Note that the _postdata field is automatically generated with the id you pass to DiagramView constructor as prefix, so it might be named differently in your project.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Mark M.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Apr 12th, 2013
Re: Exporting to Image & PDF
Reply #4 - Apr 23rd, 2013 at 7:15am
Print Post  
Hi Stoyo,

          Thanks. It's working fine now.

          Is there a possibility to include custom images that are used in ShapeNodes in the export as well?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Exporting to Image & PDF
Reply #5 - Apr 23rd, 2013 at 8:46am
Print Post  
Hi,

At this time images are not loaded automatically from ImageUrl on server side. You will have to load corresponding images from local server path explicitly, and assign them to nodes' Image property before export.

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