Save and load document content in databa

Hello

I have the document editor, and i need to save the document content in the database. I need to know if it's the best way to do it.

I have a column of type string in my database to save the document content.

I am saved in the database the answer of this this.container.documentEditor.serialize()

To load the document I use this.container.documentEditor.open (documentConted), where documentContent is what is saved in the database.

Regards.


1 Reply 1 reply marked as answer

KB Kurthis Banu Abdul Majeeth Syncfusion Team December 7, 2021 10:43 AM UTC

Hi Yosviel, 

Please check below KB in which you can load and save document in server:    

You can achieve your requirement in Document Editor with the help of server-side dependencies (either in Core or MVC).   

Webservice Link:  

Client-side sample:  
https://stackblitz.com/edit/us74xb?file=index.ts (Please find the code change in Line number 29)  

Code snippet:  
  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:5000/api/documenteditor/SaveDocument');  
  
        http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');  
        http.responseType = 'json';  
        //Serialize document content as SFDT.  
        let sfdt: any = { content: container.documentEditor.serialize() };  
        //Send the sfdt content to server side.  
        http.send(JSON.stringify(sfdt));  
      });  

Server-side Sample:  
  
Documentation Link:  

Regards,  
Kurthis Banu A.  


Marked as answer
Loader.
Up arrow icon