Document Editor - Saving the file to local

Hi there,

I'm using the Document Editor component in React Js, I created a button, trying to make it save the document once I clicked on the button.

The screenshot below is the position of the button.



Currently, I am stucked on the function saveAsBlob, how do I save the document as sfdt file format to my local disk upon clicking the button?

Can you please provide me an example on using the function to save it?


This is the code I used to check the content.

I console log it and from the console, I found the content in sfdt file format.

I copy paste it and save it manually as a sfdt file, then I use the built-in function in Document Editor to open the file, it works.

But what I want is to save the file upon clicking the button.

It would be great if you can provide me example on how to save the file to server/database and reading from server side upon open as well.

As moving onwards, I am going to do so.

This is actually a report, each report has a unique report ID, and once I clicked the selected report, it will display the content in it.

Thanks.

5 Replies

SM Suriya Murugan Syncfusion Team June 16, 2021 11:08 AM UTC

Hi Lim, 

Syncfusion Greetings! 

## Save document as sfdt in local 

Using save API or Ctrl + S, you can save document in local. 

Code snippet: 

container.documentEditor.save(‘Document’,’Sfdt’); 

## Load/save document to server 

Please check below KB link which will load document from server and save back to server: 

  


Regards, 
Suriya M. 



LZ Lim Ze Dong June 18, 2021 08:09 AM UTC

Hi there,

The reply really helped a lot, thank you for that.

Currently I noticed that the document editor only can export as Sfdt, Docx and Text file, I wonder if it has the function to export as Pdf file?

Besides that, I tried upload my resume into the document editor, and when I try to save it to local, it gives me below error:


And if I try to save it to server/database, it gives me another error:


I have tried with other documents, there is no problem at all, but only this document has this error, I wonder why, can you please investigate about it?

Please find the attachment for the resume that I used.

Edited: 
I found that when loading the document from my local disk into the document editor, it takes some time, so is there any way to make it faster? Maybe like I host it myself, is it possible? If yes then how can I do it?
And for the file upload from local, what is the maximum size for it?

Thanks in advance.

Attachment: Resume_LZD_bc3e716f.zip


KB Kurthis Banu Abdul Majeeth Syncfusion Team June 21, 2021 11:06 AM UTC

Hi Lim,  

Regarding: Export as Pdf 

We have prepared the sample based on your requirement. Kindly check it from below sample . 

Sample Link: 

In this sample, 

1.       The document content in the exported pdf is preserved as image. 
2.       You can directly download the pdf file using download option.  

 


Note: 
Kindly install below package for Pdf export   

Command to install:  
npm install @syncfusion/ej2-pdf-export  



Regarding: I found that when loading the document from my local disk into the document editor, it takes some time, so is there any way to make it faster? 

You can avoid the time delay whenever file upload, you can access the file directly from server side in APP Data folder. Kindly check below code snippet. 

public string Import (string filename) 
       
 
            string path = _hostingEnvironment.ContentRootPath + "\\App_Data\\" + filename + ".docx”. 
            Stream stream = System.IO.File.OpenRead(path); 
            stream.Position = 0; 
            WordDocument document = WordDocument.Load(stream, FormatType.Docx); 
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(document); 
            stream.Dispose(); 
            document.Dispose(); 
            return json. 
       


Regarding: Facing issue in save as SFDT  

We can reproduce the reported issue. Currently, we are validating the reported issue. We will update further details by June 24,2021. 

please let us know if you have any questions. 

Regards, 
Kurthis Banu A. 



KB Kurthis Banu Abdul Majeeth Syncfusion Team June 24, 2021 04:41 PM UTC

Hi Lim,  

Regarding: Facing issue in save as SFDT   

We have considered the reported scenario as bug and logged defect report. Fix will be included in our upcoming EJ2 patch release which is tentatively scheduled on July 28, 2021. Once included, will update you.     

You can track the status from the below feedback.      

Regards, 
Kurthis Banu A. 



SM Suriya Murugan Syncfusion Team July 28, 2021 07:33 AM UTC

Hi Lim 

We are glad to announce that our latest EJ2 release(v19.2.49) is rolled out successfully and In that release, we have added the fix for reported issue.       

Please upgrade your Ej2 package to latest version to resolve this issue.               



Regards,  
Suriya M.  


Loader.
Up arrow icon