We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DocumentEditor from json string and converting document to HTML format

Thread ID:

Created:

Updated:

Platform:

Replies:

147486 Sep 12,2019 07:41 AM UTC Sep 12,2019 10:56 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: Word Processor
Code Monkey
Asked On September 12, 2019 07:41 AM UTC



I have other requirements. Can you help me out on this or any other alternative is appreciated,
1) Requirement: Sending document content in the email body without changing the styles and document content.

Can we convert Document to pure HTML. So, that I can use this HTMLto send in Email body with the same format.


2) Can we load the document from json string. That was created from the following code 

           WordDocument document = WordDocument.Load(processTuple.Item1, GetFormatType(processTuple.Item2.ToLower()));
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);

I will be saving the above json in database. In a new request, after fetching the data from database in server side, I will modifying some styles and content and convert back to HTML format. 

Suriya Murugan [Syncfusion]
Replied On September 12, 2019 10:56 AM UTC

Hi Naren, 
 
Thank you for contacting the Syncfusion support. 
 
Can we convert Document to pure HTML. So, that I can use this HTMLto send in Email body with the same format. 
  
Yes, you can convert the document to pure HTML using Syncfusion DocIO library. Then pass the converted html to email body. 
  
Client side in below sample code check exportAsHtml method: 
  
  
  
Server side sample code: 
  
public string DocToHtml(IFormCollection data) 
        { 
Stream stream = new MemoryStream(); 
IFormFile file = data.Files[0]; 
file.CopyTo(stream); 
stream.Position = 0; 
Syncfusion.DocIO.DLS.WordDocument wordDocument = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx);             
  
//Saves the html file 
            wordDocument.Save(stream,Syncfusion.DocIO.FormatType.Html); 
stream.Position = 0; 
  
//Now, converting the stream to string  
StreamReader reader = new StreamReader( stream ); 
string text = reader.ReadToEnd(); 
// Now, you set this html string to email body 
return text;             
  
  
For your convenienet we have prepared sample, kindly check it in below link: 
  
  
Please let me know if you have any concerns. 
  
  
  
Can we load the document from json string. 
In backend, it is not possible to convert the json string to document.
  
In client side, using saveAsBlob you can convert the save the document as Docx option and get is as a blob stream and then pass that stream to server. Then proceed further for your requirement. 
  
Open the sfdt in DocumentEditor using open method and then save it using saveAsBlob method. 
  
Sample link: 
  
 
Please let me know if you have any concerns. 
 
Regards, 
 
Suriya M. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon