Web Document Editor: Using Document Permissions
Using TX Text Control, documents can be protected by restricting the formatting and editing of content. When protecting a document, it is possible to define whether the document is completely locked or formatting can be applied.

TX Text Control allows you to protect documents with specific permissions and to protect documents from editing and formatting actions. Typically, a document is protected, exceptions are applied for specific users or user groups and the document is encrypted with a password. When opening such a document with TX Text Control without providing the master password, the permissions are applied and the document is protected automatically when the EditMode property is set to ReadAndSelect.
Initialize with User Names
The following MVC code shows how to initialize the document editor with this edit mode. Additionally, a specific user name is defined using the UserNames property:
@Html.TXTextControl().TextControl(settings =>
{
settings.UserNames = new string[] { "Paul" };
settings.EditMode = EditMode.ReadOnly | EditMode.UsePassword;
}).Render()
This user name is used for all user specific actions such as track changes or document permissions. Let's consider that the user Paul is the main (admin) editor of a document. Using the Permissions tab, it is possible to add exceptions for specific users and user groups to sections by selecting text ranges and clicking on the user in the Mark Exceptions and set Users ribbon group.
Adding Users
This list of user names contains all users with active exceptions in the currently loaded document. The user is able to add additional users using the dialog box Add Users:
Adding Users Programmatically
A very typical scenario is that the user should not be allowed to add new users, but must choose from a list of existing users. This can be solved using the JavaScript API by adding users to the list of available users:
TXTextControl.ribbonPermissionsTab.registeredUserNames =
["user@textcontrol.com", "group1@textcontrol.com"];
TXTextControl.ribbonPermissionsTab.allowAdditionalUserNames = false;
After calling this code, it is only possible to add existing users (including the newly added users) to the list:
Adding Editable Regions
Using the editable
var sel = TXTextControl.selection;
sel.getStart( function( start ) {
sel.getLength( function( length ) {
TXTextControl.editableRegions.add( "user@textcontrol.com", 1, start + 1, length );
})
});
By having everything accessible programmatically using the exposed JavaScript API, you can build your own user interface to add exceptions or editable regions to the document without using the pre-designed ribbon tabs. This gives your application the required flexibility to adapt to business workflows.
The editable
TXTextControl.editableRegions.forEach( function (er) {
er.getUserName( function( username ) { console.log(username); } );
});
Also See
This post references the following in the documentation:
- Javascript: Editable
Region Collection Object - Javascript: Formatted
Text.editable Regions Property
Related Posts
ASP.NETASP.NET CoreCollaboration
Document Viewer: Processing Tracked Changes
A new feature has been rolled out with the latest update of the TX Text Control DocumentViewer that allows users to navigate through tracked changes in order to reject and accept changes in…
DocumentViewer Annotations: Highlight Text
We just published a pre-release version of the DocumentViewer that includes a new annotation feature: Text highlights. It is now possible to select text to add a comment at a specific text…
Advantages of a Modern Contract Lifecycle Management
Modern CLM systems provide streamlined processes that help companies to focus on more high-value tasks and core business functions. This article shows the advantages and how to use Text Control…
eSign Online Demo: Contract Collaboration Workflows
We published an extension to our electronic signature reference implementation that shows how to implement document collaboration workflows. A document can be shared with another user to negotiate…
Getting Started Video Tutorial: Using DS Server with Docker
This video tutorial demonstrates how to quickly set up a Docker container with your own on-premises DS Server backend. You'll learn how to spin up the container in just seconds and configure it to…