//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY"); |
WordDocument document = new WordDocument(stream, Syncfusion.DocIO.FormatType.Docx);
Stream stream1 = new MemoryStream();
document.MailMerge.RemoveEmptyGroup = true;
string[] fieldNames = new string[] { "FirstName" };
string[] fieldValues = new string[] { "Its after replacing" };
//Execute mail merge
document.MailMerge.Execute(fieldNames, fieldValues);
document.Save(stream1, Syncfusion.DocIO.FormatType.Docx);
string sfdtText = "";
EJ2WordDocument document = EJ2WordDocument.Load(stream1, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
// Open the return string in DocumentEditor open method
return sfdtText; |
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:
For your convenienet we have prepared sample, kindly check it in below link:
| |
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:
|