Convert sfdt to html

Hello, is it possible to show preview of sfdt file as html? Is there some api to convert sfdt to html?

10 Replies

HC Harini Chellappa Syncfusion Team March 3, 2020 12:00 PM UTC

Hi Olga, 

Syncfusion Greetings! 

Document editor provides option to convert SFDT to html in server-side with the help of Word Editor package. 

Please check with following package links platform-wise. 
 
 
ASP.NET Core 
 
 
 
ASP.NET MVC5 
 
 
 
ASP.NET MVC4 
 

Sample code snippet which converts SFDT to html 

            Stream document = Syncfusion.EJ2.DocumentEditor. WordDocument.Save(sfdtString, Syncfusion.EJ2.DocumentEditor.FormatType.Html); 
            FileStream file = new FileStream("sample.html", FileMode.OpenOrCreate, FileAccess.ReadWrite); 
            document.CopyTo(file); 
            file.Close(); 
            document.Close(); 
 

Please try the above and let us know if this helps you. 

Regards, 
Harini C 



HC Harini Chellappa Syncfusion Team March 3, 2020 12:01 PM UTC

Hi Olga, 

Syncfusion Greetings! 

Document editor provides option to convert SFDT to html in server-side with the help of Word Editor package. 

Please check with following package links platform-wise. 
 
 
ASP.NET Core 
 
 
 
ASP.NET MVC5 
 
 
 
ASP.NET MVC4 
 

Sample code snippet which converts SFDT to html 

            Stream document = Syncfusion.EJ2.DocumentEditor. WordDocument.Save(sfdtString, Syncfusion.EJ2.DocumentEditor.FormatType.Html); 
            FileStream file = new FileStream("sample.html", FileMode.OpenOrCreate, FileAccess.ReadWrite); 
            document.CopyTo(file); 
            file.Close(); 
            document.Close(); 

Please try the above and let us know if this helps you. 

Regards, 
Harini C 



AL Alexey March 5, 2020 07:55 AM UTC

Hello, I use your code, but nothing work, could you please show demo project with this function?
[HttpPost]
[Route("sfdt-to-html")]
public string SfdtToHtml(string sfdt)
{
Stream document = Syncfusion.EJ2.DocumentEditor.WordDocument.Save(sfdt, Syncfusion.EJ2.DocumentEditor.FormatType.Html);
FileStream file = new FileStream("sample.html", FileMode.OpenOrCreate, FileAccess.ReadWrite);
document.CopyTo(file);
file.Close();
document.Close();
}


SM Suriya Murugan Syncfusion Team March 6, 2020 06:11 AM UTC

Hi Olga, 

We have prepared the sample for your requirement with front end in Vue and back end in ASP.Net Core with following options. 
1.      In sample, html(.html) under Download option allows you to save the document in HTML format in server side. 
 
2.      To run front end use following commands: 
a.      npm install 
b.      npm run dev 
3.      Check onExportToHtml method in front end and ExportSFDT in back end. 

Sample link: 



Note: Front End sample is depending on WEP API to save and open the document. So, you need to run both front end sample and ASP.NET Core Web API sample simultaneously.   
 
For your reference , Documentation link in typescript: 

Please let me know if you have any questions. 

Regards, 
Suriya M. 



HM Harshal Mahajan replied to Suriya Murugan May 31, 2021 12:20 PM UTC

Hi Olga, 

We have prepared the sample for your requirement with front end in Vue and back end in ASP.Net Core with following options. 
1.      In sample, html(.html) under Download option allows you to save the document in HTML format in server side. 
 
2.      To run front end use following commands: 
a.      npm install 
b.      npm run dev 
3.      Check onExportToHtml method in front end and ExportSFDT in back end. 

Sample link: 



Note: Front End sample is depending on WEP API to save and open the document. So, you need to run both front end sample and ASP.NET Core Web API sample simultaneously.   
 
For your reference , Documentation link in typescript: 

Please let me know if you have any questions. 

Regards, 
Suriya M. 


Hello sir I can you plz prepare sample with front end in React.js and back end in Node.js with following options using @syncfusion/ej2-react-documenteditor
1.      In sample, html(.html) under Download option allows you to save the document in HTML format in server side. 



KB Kurthis Banu Abdul Majeeth Syncfusion Team June 1, 2021 07:09 AM UTC

Hi Harshal, 

Regarding:  I can you plz prepare sample with front end in React.js and back end in Node.js  

Document Editor doesn’t have support in backend Node.js.  

For your reference, kindly refer the below webservice link.  


We will provide the sample based on your requirement frontend React.js and backend ASP.Net Core or MVC.  

Please let us know whether this will satisfy your requirement. If yes, we will provide sample based on that.   

Regards, 
Kurthis Banu A. 



VG Viorel Gabriel Mocanu February 3, 2022 11:40 AM UTC

Hi,

I tried your example from above, but even though the exporting in docx and SFDT it's working, for the exporting in HTML I got an issue. Can you help me solve this one?
I got this error on the backend side and I think it's related to your API:

System.Collections.Generic.KeyNotFoundException: 'The given key 'protectionType' was not present in the dictionary.'

This exception is trigger after calling this line of code:

Stream document = WordDocument.Save(data.content, FormatType.Html);

Best regards,
Gabriel





SM Suriya Murugan Syncfusion Team February 4, 2022 04:49 AM UTC

Hi Gabriel, 

We have tried to reproduce the reported issue in version 19.4.0.48 but couldn’t. 

Can you please share your document editor version details, and also can you please confirm whether you were facing issue for specific document or all documents? if specific document, please share the document that will be helpful for us to proceed further and provide you the solution at the earliest. 

Regards, 
Suriya M. 



VG Viorel Gabriel Mocanu replied to Suriya Murugan February 8, 2022 02:36 PM UTC

Hi Suriya,

Thanks for fast reply. Upgrade the version to 19.4.0.48 resolved the issue.

Best regards,
Gabriel



SM Suriya Murugan Syncfusion Team February 9, 2022 05:45 AM UTC

Hi Gabriel,


Thanks for your update.


Regards,

Suriya M.


Loader.
Up arrow icon