On Word editor save data on change in word file

Before I used a button for saving the data on word editor but now we want to save data when the user changes the value in the word file.
So one kind of future that the user wants to saves the data while they updating the documents. So is there any event that exists in the word editor which calls while the user updates anything in documents. ? so using that I can able to save the updated data. 

On the Same Page, I have multiple SfDocumentEditorContainer as pre-given sample code and for achieving the above features I used the below ContentChanged method but it works sometimes and sometimes giving an error that object reference not set. Can you please guide us is there any way to achieve the above features which we want? Thanks.


  public async void OnDocumentChange(Syncfusion.Blazor.DocumentEditor.ContainerContentChangeEventArgs args, int position)
    {
        try
        {
            
            DocumentEditorModule editor = containerList[position].GetDocumentEditor();
            string base64Data = await editor.SaveAsBlob(FormatType.Docx);
            byte[] data = Convert.FromBase64String(base64Data);

            ReviewAnswers[0].Answer = data;
            await SaveOnChange(ReviewAnswers[position]);
        }
        catch (Exception ex)
        {

            throw;
        }

    }

// Sample Code 

 @for (var i = 0; i < ReviewAnswers.Count; i++)
                        {

 var position = i;
 <SfDocumentEditorContainer Height="670px" Width="1250px" @ref="containerList[position]" EnableToolbar=true ToolbarItems="@ToolbarItemsWord">
                                        <DocumentEditorContainerEvents Created="@(e =>OnLoad(e,position))" OnToolbarClick="@(e =>onItemClick(e,position))" ContentChanged="@(e =>OnDocumentChange(e,position))"></DocumentEditorContainerEvents>
                                    </SfDocumentEditorContainer>


}

7 Replies 1 reply marked as answer

KB Kurthis Banu Abdul Majeeth Syncfusion Team May 20, 2021 01:56 PM UTC

Hi Karan,    

We are cross checked your reported issue. We suspect probably parent object should be undefined. could you kindly check it from your side? 

From further analysis, while seeing the provided code snippet. it seems blazor version should be a lower. Kindly upgrade latest version (19.1.64) to resolve your reported issue. 

Regards, 
Kurthis Banu A. 



KP Karan Patel May 24, 2021 06:11 PM UTC

Hello Kurthis Banu,

I tried with an update but it does not work and giving the same errors. 
Can you please make one sample for me if possible with multiple SfDocumentEditorContainer on one page and in which I can able to update each SfDocumentEditor on editing the SfDocumentEditor?

Thanks.


KB Kurthis Banu Abdul Majeeth Syncfusion Team May 25, 2021 01:22 PM UTC

Hi Karan, 

Regarding:  tried with an update but it does not work and giving the same errors.  

We suspect issue may be adding the Toolbar items. Please modify your code from below code snippet to resolve your reported issue.   

Code snippet:  
List<Object> ToolbarItem = new List<Object>
{
new CustomToolbarItemModel() {Id=”back”  Text = "Back" prefixIcon =”e-back”}
}; 
 
  


Regarding: Sample  

We are prepared the sample based on your requirement. kindly check it from below link. 



In this sample, 

1.       We have created DocumentEditorContainer and DocumentEditor instance. 
2.       If you modified the content in DocumentEditorContainer instance, based on changes it will be reflect in DocumentEditor instance like MS word split view module. 

Please let us know whether this will satisfy your requirement.  


Regards, 
Kurthis Banu A. 


Marked as answer

KP Karan Patel replied to Karan Patel May 26, 2021 02:41 AM UTC

Hello Kurthis Banu,

I tried with an update but it does not work and giving the same errors. 
Can you please make one sample for me if possible with multiple SfDocumentEditorContainer on one page and in which I can able to update each SfDocumentEditor on editing the SfDocumentEditor?

Thanks.

Hi Kurthis Banu,

I tried with the below code fixing but didn't work out.
List<Object> ToolbarItem = new List<Object>
{
new CustomToolbarItemModel() {Id=”back”  Text = "Back" prefixIcon =”e-back”}
}; 
 

PFA attached one Index.razor file which updated by me within your given solution and that help you to understand that what I am want to achieve. 

Attachment: Index_2209474a.7z


KB Kurthis Banu Abdul Majeeth Syncfusion Team May 26, 2021 05:06 PM UTC

Hi Karan, 

We need some clarification regarding your reported issue. Kindly share us more detail about the reported problem such as screenshot or video demonstration of the reported problem, which will be helpful for us to investigate further and provide you the solution at the earliest.  
  
Regards, 
Kurthis Banu A. 



KP Karan Patel June 15, 2021 03:12 AM UTC

Hello Kurthis Banu,

 I update the new version as per the thread"https://www.syncfusion.com/forums/164129/blazor-documenteditor-saveasblob-throwing-nullreference-exception" that the old version has some bugs in sfdoceditor on "SaveAsBlob" method and I get the same so for fixing my issues I update my current version to the latest.
SO after Updated the latest version 19.1.0.67 I get the below error on my current project so can you please look that what this error means?
Please find attached the zip file which contains a screenshot of errors. 


Attachment: Desktop_dd086095.7z


KB Kurthis Banu Abdul Majeeth Syncfusion Team June 15, 2021 07:43 AM UTC

Hi Karan,  

We tried to reproduce the reported issue. We need some clarification regarding your reported issue, which time you are facing the reported issue. So, Kindly share us more detail about the reported problem. 

For your reference, we have attached the sample application which we used to reproduce the reported issue and it can be downloaded from the below link.  

Sample Link:  

If you are facing any issues, kindly modify the above sample and share us same.  

Regards, 
Kurthis Banu A. 


Loader.
Up arrow icon