In this blog, we will show you how to restrict editing in a Word document based on user in a web application using the Syncfusion Word Processor (a.k.a. document editor). You can easily select parts or regions in the document and choose the users who can edit them freely. This works independently without Microsoft Word or Office interop dependencies.
Word Processor (document editor) component supports locking or protecting a Word document from editing with four types of restrictions:
- Read only: Allows no changes in the document.
- Filling in forms: Allows the user only to fill the form fields in the document.
- Comments: Allows the user only to add new comments or edit an existing comment in the document.
- Tracked changes: Allows the user to edit the document, but all the changes are tracked. Those tracked changes can be accepted or rejected only after unlocking with a password.
You can open the Restrict Editing pane by choosing Protections in the Restrict Editing dropdown.
The following screenshot illustrates the Restrict Editing pane of the Word Processor component.
Select content and add edit permissions for users
Microsoft Word has a unique option to add an exception to a part of the content and choose the users who can freely edit it when the document is protected with read-only editing restrictions. The Syncfusion Word Processor component has the same functionality. The document’s editable regions will be highlighted by default. You can customize the highlight color with the userColor property in your application.
The following GIF image illustrates how to select part of the content in a Word document and add users as exceptions to its read-only status in the Syncfusion Word Processor component.
If you want to remove an editable region, select that region in the document (or place the cursor in the highlighted region) and uncheck the specific user in the exceptions list.
You can protect the document with a password before sending it to other collaborators. The other users can read the entire document but modify it only in the editable region marked for them.
Once you have prepared and finalized the document, click Yes, Start Enforcing Protection in the Restrict Editing pane.
The password pop-up will open. Set the required password and confirm it. Now, the document is ready to share with other collaborators.
Navigate to editable region marked for the user
In your web application, you should configure the currentUser property with the user who opens the application. The Word Processor component automatically highlights the editable regions marked for that user, while other editable areas in the document will be non-editable.
The Word Processor provides an intuitive option to navigate to the editable regions of the current user in a Word document.
For more information, refer to the complete, working example of restricting editing based on user in Word Processor.
With the help of the Syncfusion Word Processor, you can easily create a Word document with user-specific editable regions and protect the document with a password in your web application.
Take a moment to peruse the getting started documentation, where you’ll find other options and features, all with accompanying code examples. You can see the documentation for more information about the restricted editing functionality.
Please let us know in the comments below if you have any questions about these features. You can also contact us through our support forum, support portal, or feedback portal. We are happy to assist you!