Model.Attchment contains the byte[] of the document. It comes to the client side with my script, but not displayed in the Document Editor.
This is the script I'm using :
<script>
var base64Content = "@Html.Raw(Convert.ToBase64String(Model.Attachment))";
var documentEditor = new ej.documenteditor.DocumentEditor({
isReadOnly: false
});
documentEditor.appendTo('#documenteditor_titlebar');
// Function to load the document into the Document Editor
function loadDocument() {
documentEditor.open({
document: {
fileContent: base64Content,
fileName: "document.docx",
fileType: "Docx",
}
});
}
// Load the document when the DOM content is fully loaded
document.addEventListener("DOMContentLoaded", function () {
loadDocument();
});
</script>
In DocumentEditor, when opening a document other than SFDT (Syncfusion Document Editor’s native file format), the server-side web API is invoked from a client-side script.
Client: Sends the input file. Server: receives the input file and sends the converted SFDT back to the client.
And in the client, open the received SFDT using the documentEditor open API.
The server-side web API internally extracts the content from the document (DOCX, DOC, WordML, RTF, HTML) using the Syncfusion Word library (DocIO) and converts it into SFDT for opening the document in Document Editor.
Code snippet:
Server side:
[Route("Load")]
Client side:
var documentEditor = new ej.documenteditor.DocumentEditor({
)
.then(response => {
})
.then(json => {
})
.catch(error => {
}); }
UG documentation to know about documentEditor overview: https://ej2.syncfusion.com/documentation/document-editor/overview