Hello,
I have set up the basic for Document editor and now wanted to load existing documents that are in the string/HTML format in the editor. For server side, I am using the docker image provided in https://hub.docker.com/r/syncfusion/word-processor-server from article https://www.syncfusion.com/blogs/post/view-and-edit-word-documents-in-angular.aspx.
Can you please provide some samples of the same?
Thanks,
Mansi
|
string htmltags = "<?xml version='1.0' encoding='utf - 8'?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN''http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns ='http://www.w3.org/1999/xhtml' xml:lang='en' lang ='en'><body><h1>The img element</h1><img src='https://www.w3schools.com/images/lamp.jpg' alt ='Lamp Image' width='500' height='600'/></body></html>";
WordDocument document = WordDocument.LoadString(htmltags,FormatType.Html);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(document);
document.Dispose();
return json; |
|
container.documentEditor.editor.paste(“provide sfdt here”); |
|
document.getElementById('export').addEventListener('click', () => {
let http: XMLHttpRequest = new XMLHttpRequest();
// Run the web service then replace the service URL by running local URL.
http.open('POST', 'http://localhost:50574/api/documenteditor/ ExportAsHTML');
http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
http.responseType = 'json';
let sfdt: any = { content: container.documentEditor.serialize() };
http.send(JSON.stringify(sfdt));
}); |
|
public string ExportAsHTML([FromBody] SaveParameter data)
{
Stream document = Syncfusion.EJ2.DocumentEditor.WordDocument.Save(data.content, Syncfusion.EJ2.DocumentEditor.FormatType.Html);
FileStream filestream = new FileStream(path + "/ouput.html", FileMode.OpenOrCreate, FileAccess.ReadWrite);
document.CopyTo(filestream);
StreamReader reader = new StreamReader(document);
string html = reader.ReadToEnd();
reader.Close();
document.Close();
return html;
}
|