Document redlining or known as track changes is a feature of TX Text Control that allows users to see changes made to a document. This feature is commonly used in collaborative editing scenarios where multiple users are working on the same document. The changes are displayed in a different color and can be accepted or rejected by the user.

Specifically used in legal and medical documents, this feature is a must-have for applications that require document collaboration. Contracts, agreements, and other legal documents are often reviewed by multiple parties and the track changes feature helps to visualize and to keep track of changes made to the document.

This article shows how to enable the track changes feature in TX Text Control and how to accept or reject changes programmatically and how to use the visual components of TX Text Control to visualize and manage changes.

MS Word Compatible

TX Text Control allows you to track changes compatible with MS Word and supports this feature in Office Open XML DOCX, DOC, RTF and other supported formats. Changes made to a document in MS Word or Google Docs are visible and accessible in TX Text Control, so it doesn't matter where the document is being edited - you have full control over the changes made.

The following track change functions are available in TX Text Control:

  • Keep track of text additions and deletions
  • Define current author (user name) for changes
  • Display changes in different colors
  • Display changes in a separate pane
  • Tracking of change, author and time stamp
  • Access, accept or reject changes programmatically
  • Filter changes

Enable Track Changes

To enable track changes in the visual document editor, the following view code is required to set the current author by setting the username:

@using TXTextControl.Web.MVC
@Html.TXTextControl().TextControl(settings =>
{
settings.UserNames = new string[] { "Tim Typer" };
settings.Dock = TXTextControl.Web.DockStyle.Window;
}).Render()
view raw test.cshtml hosted with ❤ by GitHub

After setting the current author, the track changes feature can be enabled by toggling the Track Changes toggle button:

Track changes with TX Text Control

Or programmatically by setting the isTrackChangesEnabled property:

TXTextControl.isTrackChangesEnabled = true;
view raw test.js hosted with ❤ by GitHub

The changes are displayed in a different color and can be accepted or rejected by the user. The sidebar shows the changes and allows the user to navigate through the changes:

Track changes with TX Text Control

Comments can be added to connected tracked changes and can be displayed in the sidebar:

Track changes with TX Text Control

Document Viewer

The Document Viewer can also be used to load a document that contains tracked changes. They will be visualized and a special mode will be active to navigate through the changes to accept or reject them. This is especially helpful in mobile applications where the full-featured editor is not helpful.

The following code shows how to load a document with tracked changes in the Document Viewer:

@using TXTextControl.Web.MVC.DocumentViewer
@Html.TXTextControl().DocumentViewer(settings =>
{
settings.DocumentPath = "Data/nda_styled_tracked.tx";
settings.UserNames = new string[] { "Tim Typer" };
settings.Dock = DocumentViewerSettings.DockStyle.Window;
}).Render()
view raw test.cshtml hosted with ❤ by GitHub

After loading the document, the changes are displayed in the Document Viewer:

Track changes with TX Text Control

The mobile view of the Document Viewer shows the changes and allows the user to navigate through the changes in a dedicated toolbar:

Track changes with TX Text Control

Access Changes Programmatically

TX Text Control provides a powerful API to access, accept or reject changes programmatically. The following code shows how to loop through all changes and to display the change type, author and time stamp:

using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load("Data/nda_styled_tracked.tx", TXTextControl.StreamType.InternalUnicodeFormat);
foreach (TXTextControl.TrackedChange change in tx.TrackedChanges)
{
Debug.WriteLine(change.UserName);
Debug.WriteLine(change.Text);
Debug.WriteLine(change.ChangeKind);
Debug.WriteLine(change.ChangeTime);
}
}
view raw test.cs hosted with ❤ by GitHub

To accept or reject a change, the following code can be used:

using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load("Data/nda_styled_tracked.tx", TXTextControl.StreamType.InternalUnicodeFormat);
TXTextControl.TrackedChange trackedChange = tx.TrackedChanges[0];
tx.TrackedChanges.Remove(trackedChange, true);
}
view raw test.cs hosted with ❤ by GitHub

The TrackedChangeCollection provides the Remove TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
TrackedChangeCollection Class
Remove Method
Removes a tracked change from the collection.
method with the accept parameter that defines whether the change should be accepted or rejected.

Conclusion

TX Text Control provides a powerful track changes feature that is compatible with MS Word and other word processing applications. This feature is a must-have for applications that require document collaboration and document redlining. The API provides methods to access, accept or reject changes programmatically.