How to load SDFT data to WordDocument class directly?

I am trying to creating an API loading SDFT directly and convert it back to the original format.

I searched for samples but I couldn't find a valid solution.


3 Replies

MR Manikandan Ravichandran Syncfusion Team March 23, 2020 12:16 PM UTC

Hi Adam,

Thank you contacting Syncfusion support.

Document editor provides option to save the document in client as well as server side.

Kindly refer the below documentation on exporting the contents as word documents.

https://ej2.syncfusion.com/aspnetcore/documentation/document-editor/export/?no-cache=1

you can also pass SFDT string to server and convert it word documents. Please refer the below code snippet for converting SFDT string to desired format stream. You can then save the stream

 
Stream document = Syncfusion.EJ2.DocumentEditor.WordDocument.Save(sfdtString, Syncfusion.EJ2.DocumentEditor.FormatType.Docx); // you can pass any of the supported format types which includes doc, docx, rtf, txt, html.  

Note: To use the above API, you have install WordEditor Packages platform-wise.
https://www.nuget.org/packages/Syncfusion.EJ2.WordEditor.AspNet.Core/18.1.0.36-beta
https://www.nuget.org/packages/Syncfusion.EJ2.WordEditor.AspNet.Mvc5/18.1.0.36-beta
https://www.nuget.org/packages/Syncfusion.EJ2.WordEditor.AspNet.Mvc4/18.1.0.36-beta

To get the SFDT string in client-side, please use serialize API of document editor, which returns the current document content as SFDT JSON string.

https://ej2.syncfusion.com/documentation/api/document-editor#serialize

Sample Code Snippet:

 
Document editor container
ContainerInstance.documentEditor.serialize();
Document editor
documentEditorInstance.serialize()
 

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran



AA Adam Aiken March 25, 2020 12:40 AM UTC

Thank you for the information.

Can we export SDFT data using DocIO?


HC Harini Chellappa Syncfusion Team March 25, 2020 11:47 AM UTC

Hi Adam, 

Using DocIO, we cannot convert to SFDT. 

But you can pass the saved stream from DocIO to Document Editor Load API to convert it to SFDT string. 

Sample Code Snippet 

// stream saved via DocIO 
 
Syncfusion.EJ2.DocumentEditor.WordDocument document = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx); 
 
string sfdtJson = Newtonsoft.Json.JsonConvert.SerializeObject(document); 
 

Please refer the below documentation for saving the document as stream using DocIO. 


If your requirement is to pass the document content as sfdt to server and save it then please refer the below documentation. 


Please let us know if you need any further assistance on this. 

Regards, 
Harini C 


Loader.
Up arrow icon