Restrict editing areas

Hi,

I need to protect certain areas in my document, the restriction feature works very well, but it is done manually.

I need to do this programmatically in the backend of my application and return the sfdt with protected areas, I tried to do it but I wasn't successful


An alternative from the SyncFusion team which is to put the protected areas inside a bookmark and in the document's change event it doesn't allow removing if the mouse cursor is inside a bookmark, this solution works but if I insist by clicking and typing an exception is generated in editor and after that you can edit the content inside the bookmark.


Is there any solution to this issue?




5 Replies

KB Kurthis Banu Abdul Majeeth Syncfusion Team September 10, 2021 12:35 PM UTC

Hi Tiago Luz, 

You can restrict programmatically in in server side by using Syncfusion.DocIO library.Please find the documentation link in below 

DOCIO Documentation Link: 

Please let us know if you have any questions. 

Regards, 
Kurthis Banu A. 



TL Tiago Luz September 10, 2021 01:49 PM UTC

Hi Kurthis, in the documentation it just shows how to protect the entire document, what I need is to specify parts of the document that I want to protect.

Like the image below, but I want to do this programmatically:




SM Suriya Murugan Syncfusion Team September 13, 2021 06:29 AM UTC

Hi Tiago Luz, 

In backend, it is not possible to protect the part of document programmatically. 

In front end, you can programmatically achieve your requirement. 

Select the content which you want to protect 
//When the document is protected allows the provided user to edit the selected content. If user is not provided, “Everyone” is allowed to edit. 
 
container.documentEditor.editor.insertEditingRegion(“username”); 
 
// Enforce document protection have to specify password, whether to limit formatting or not, whether isReadOnly or not 
container.documentEditor.editor.enforceProtection('123',false,true); 
 
//stop the document protection 
container.documentEditor.editor.stopProtection('123'); 
 
Please refer the below documentation for API details. 


Please let us know if you have any questions. 

Regards, 
Suriya M. 




TL Tiago Luz October 5, 2021 05:45 PM UTC

Thanks for the response Suriya, but doing this from the front end would not meet our requirements.


Is there any change to consider this feature in future releases?

This is important for us to be able to do this from the backend.



KB Kurthis Banu Abdul Majeeth Syncfusion Team October 6, 2021 12:50 PM UTC

Hi Tiago, 


Thank you for your update. 


As mentioned earlier, currently we don’t have a support for restrict/allow editing the particular part of the Word document in DOCIO (back end). We have already logged this as a feature request in our database. We don’t have any immediate plans to implement this feature. We will let you know when this feature is implemented.

The status of the feature can be tracked through below link:
https://www.syncfusion.com/feedback/3173/restrict-editing-for-a-range-or-group-of-elements-in-word-document

For your requirement of editing the particular part of the document, you can use Form Fields in the document which can editable even we set password protection. Please refer the below link to know more about the password protection of form field. 

https://help.syncfusion.com/file-formats/docio/working-with-security#protecting-word-document-from-editing

We have attached the simple word document with some form field and also output document which is saved with password protection using DocIO. 

https://www.syncfusion.com/downloads/support/forum/168737/ze/Template801368748

Please refer the below code example for the same.  
WordDocument document = new WordDocument(@"input.docx");
//Sets the protection with password and it allows only to modify the form fields type
document.Protect(ProtectionType.AllowOnlyFormFields, "password");
//Saves and closes the Word document instance
document.Save("Sample.docx", FormatType.Docx);
document.Close();  
  

Please let us know if you have any other queries. 

Regards, 
Kurthis Banu A. 


Loader.
Up arrow icon