Products Technologies Demo Docs Blog Support Company

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.

Web Document Editor: Using Document Permissions

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.

Document Permissions

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:

Document Permissions

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:

Document Permissions

Adding Editable Regions

Using the editableRegions property, it is possible to access existing regions as well as adding additional regions. The following code adds an editable region to the document for user user@textcontrol.com:

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 editableRegionCollection can be used to iterate over all existing regions in a document. The following code shows the user name of every editable region in the current document:

TXTextControl.editableRegions.forEach( function (er) {
  er.getUserName( function( username ) { console.log(username); } );
});

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Also See

This post references the following in the documentation:

  • Javascript: EditableRegionCollection Object
  • Javascript: FormattedText.editableRegions 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…


AngularASP.NETAnnotations

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…


AngularASP.NETCLM

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…


AngularASP.NETCollaboration

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…


ASP.NETASP.NET CoreDS Server

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…