let json: string = this.container.documentEditor.serialize();
this.container.documentEditor.open(json);
|
// Pass your stream here
Stream stream = new MemoryStream(byteArray(provide your byte array here));
WordDocument document = WordDocument.Load(stream, GetFormatType(type));
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
// Releases unmanaged and optionally managed resources.
document.Dispose();
stream.Close();
// will get sfdt to load in Documenteditor
return json;
internal static Syncfusion.EJ2.DocumentEditor.FormatType GetFormatType(string format)
{
if (string.IsNullOrEmpty(format))
throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
switch (format.ToLower())
{
case ".dotx":
case ".docx":
case ".docm":
case ".dotm":
return Syncfusion.EJ2.DocumentEditor.FormatType.Docx;
case ".dot":
case ".doc":
return Syncfusion.EJ2.DocumentEditor.FormatType.Doc;
case ".rtf":
return Syncfusion.EJ2.DocumentEditor.FormatType.Rtf;
case ".txt":
return Syncfusion.EJ2.DocumentEditor.FormatType.Txt;
case ".xml":
return Syncfusion.EJ2.DocumentEditor.FormatType.WordML;
case ".html":
return Syncfusion.EJ2.DocumentEditor.FormatType.Html;
default:
throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");
}
} |
Stream document = Syncfusion.EJ2.DocumentEditor.WordDocument.Save(data.content, //Provide your required format type here);
// it will return byte array
return ms.ToArray();
From this stream you can convert to varbinary for your requirement |