Review Word Documents with Track Changes and Comments in a Web Application
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (175).NET Core  (29).NET MAUI  (208)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (220)BoldSign  (15)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (67)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (101)Streamlit  (1)Succinctly series  (131)Syncfusion  (920)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (37)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (151)Chart  (132)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (633)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (41)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (508)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (11)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (597)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Review Word Documents with Track Changes and Comments in a Web Application

Review Word Documents with Track Changes and Comments in a Web Application

In this blog, we are going to see how easy it is to review a Word document using Syncfusion’s Word framework. Comments and track changes are features provided in Microsoft Word for reviewing. In a similar way, our Word framework includes support to track changes, accept or reject the tracked changes, and insert, reply, resolve, and delete comments. The most interesting thing is it works without Microsoft Word or Office interop dependencies.

Syncfusion Word Processor (also known as Document Editor) is a user interface web component that allows you to compose, edit, view, and print Word documents interactively in a web application. It provides all the standard word processing features such as formatting contents, resizing images and tables, finding and replacing text, generating tables of content, and so on. This component is available in JavaScript (ES5 and ES6), Angular, React, Vue, ASP.NET MVC, ASP.NET Core, and Blazor platforms.

Note: The Word Processor (Document Editor) component requires server-side interaction for the following operations:

  • Open Word documents (converting Word documents to SFDT file format).
  • Paste content with formatting.
  • Restrict editing.
  • Spell checking.

Syncfusion provides a server-side library for the following platforms:

You can find the web API projects for the supported platforms in this GitHub repository.

Comments

Comments are notes, questions, and suggestions that a reviewer or reader offers to other people working on a Word document. The Syncfusion Word Processor component allows you to do the following actions with comments:

  • Insert a new comment for the selected content.
  • Edit an existing comment.
  • Reply to a comment.
  • Mark a comment as resolved once the suggested action or change is done.
  • Delete a single comment or all comments.

Since the Document Editor component is modularized, not all the features are enabled by default. To enable the commenting ability, set the enableComment property as true. By default, the enableComment property is set to false, so commenting is disabled in the DocumentEditor component.

Note: The commenting feature will be enabled by default when using the DocumentEditorContainer component.

To insert a new comment, select the text that you want to comment on. Then, click either the Comments option in the toolbar or the New comment option in the review tab, as shown in the image below. The editor will set the author for the new comment based on the value of the currentUser property.

Document editor component with comments
Document editor component with comments

In the new comment box of the review tab, add the necessary content and click the post icon. If you want to discard the comment, then click the cancel icon.

Posting or discarding a comment
Posting or discarding a comment

To edit an existing comment, click the options button in the comment and then click Edit. Now you can edit the comment text.

The edit, delete, reply, and resolve options of a comment
The edit, delete, reply, and resolve options of a comment

Similarly, you can delete, reply to, and resolve a comment using the other options. The re-open option will be displayed only for a resolved comment.

Track changes

The track changes feature tracks all the insertions and deletions made to the Word document. You can see what was inserted or deleted in a specific document by whom and when. Also, it allows you to accept or reject the changes made to the document.

Syncfusion greatly facilitates the developer community with feature-rich Word processing components that allow developers to add advanced Word document reviewing capabilities within their applications. The products are:

  • An advanced Word Processor (editor) for tracking changes in a Word document that provides an intuitive user interface in web applications.
  • A comprehensive Word Library that allows users to access and accept or reject the tracked changes in a Word document using powerful APIs in .NET and Java.

Intuitive user interface for tracking changes

When the track changes option is enabled in the Word Processor, the edits or changes made are marked with:

  • A strikethrough for deleted information.
  • An underline for inserted information.

The Word Processor provides an intuitive user interface to do the following actions with the track changes feature:

  • Enable or disable track changes feature.
  • Access all the tracked revisions.
  • Accept or reject a specific change.
  • Accept or reject all changes.
  • Filter changes based on users.
  • Navigate between changes.

To enable or disable track changes in the Document Editor, toggle the Track Changes option in the toolbar.

Enabling track changes in Document Editor
Enabling track changes in Document Editor
Options for viewing, accepting, or rejecting tracked changes
Options for viewing, accepting, or rejecting tracked changes

Witness the power of the Syncfusion Word Library in action with the examples featuring its dynamic functionalities.

Accept or reject changes

Syncfusion provides a comprehensive Word Library in both .NET (C#, VB.NET) and Java, giving you complete freedom in choosing the best fit for server-side automation code for your projects. It provides powerful APIs to access revisions (tracked changes) and accept or reject a change or group of changes.

You can automate accepting or rejecting tracked changes on the server side using the Syncfusion Word Library before displaying the Word document in the web browser. Before accepting or rejecting the changes, you can validate and filter the changes based on:

  • Authors
  • Revision types (insertion, deletion, formatting, move from, move to, style definition change).

The following images show the tracked changes in a Word document.

Tracked changes in a Word document
Tracked changes in a Word document

Accept the changes

The following C# code example illustrates how to accept all the changes made by an author in a Word document using the Word Library.

//Reads the input Word document.
Stream inputStream = File.OpenRead(Path.GetFullPath(@"../../../../../../Data/InputWithTrackedChanges.docx"));
string authorName = "Steven Buchanan";
int acceptedChangesCount = AcceptChanges(inputStream, authorName);
Console.WriteLine("Accepted {0} changes made by {1}.", acceptedChangesCount, authorName);

static int AcceptChanges(Stream inputStream, string authorName)
{
    int acceptedChangesCount = 0;
    //Creates new Word document instance for Word processing.
    using (WordDocument document = new WordDocument())
    {
        //Opens the Word document containing tracked changes.
        document.Open(inputStream, FormatType.Docx);
        inputStream.Dispose();
        //Iterates all the revisions present in the Word document.
        for (int i = document.Revisions.Count - 1; i >= 0; i--)
        {
            //Validates the author of current revision to accept/reject it.
            if (document.Revisions[i].Author == authorName)
            {
                //Accepts the current revision.
                document.Revisions[i].Accept();
                acceptedChangesCount++;
            }
            //Resets i to last item, since accepting one revision will impact all its related revisions and leads to change in Revsions
            if (i > document.Revisions.Count - 1)
                i = document.Revisions.Count;
        }
        //Saves the Word document as DOCX format
        using (Stream docStream = File.Create(Path.GetFullPath(@"../../../OutputAfterAcceptingChanges.docx")))
        {
            document.Save(docStream, FormatType.Docx);
        }
    }
    return acceptedChangesCount;
}

For more information, refer to the accept all changes made by an user project sample.

The resultant Word document looks as follows.

Word document after accepting changes made by a user
Word document after accepting changes made by a user

Similarly, you can filter all the changes made by an author and reject the filtered changes.

Reject the changes

The following C# code example illustrates how to reject the insert and delete revisions made by all authors and keep the formatting changes in a Word document using the Word Library.

//Reads the input Word document.
Stream inputStream = File.OpenRead(Path.GetFullPath(@"../../../../../../Data/InputWithTrackedChanges.docx"));
RevisionType revisionType = RevisionType.Insertions | RevisionType.Deletions;
int rejectedChangesCount = RejectChanges(inputStream, revisionType);

static int RejectChanges(Stream inputStream, RevisionType revisionType)
{
    int rejectedChangesCount = 0;
    //Creates new Word document instance for Word processing.
    using (WordDocument document = new WordDocument())
    {
        //Opens the Word document containing tracked changes.
        document.Open(inputStream, FormatType.Docx);
        inputStream.Dispose();
        //Iterates all the revisions present in the Word document.
        for (int i = document.Revisions.Count - 1; i >= 0; i--)
        {
            //Validates the revision type of current revision to accept/reject it.
            if ((document.Revisions[i].RevisionType & revisionType) != 0)
            {
                //Rejects the current revision.
                document.Revisions[i].Reject();
                rejectedChangesCount++;
            }
            //Resets i to last item, since rejecting one revision will impact all its related revisions. and lead to change in Revsions.
            if (i > document.Revisions.Count - 1)
                i = document.Revisions.Count;
        }
        //Saves the Word document as DOCX format.
        using (Stream docStream = File.Create(Path.GetFullPath(@"../../../OutputAfterRejectingChanges.docx")))
        {
            document.Save(docStream, FormatType.Docx);
        }
    }
    return rejectedChangesCount;
}

For more information, refer to the reject all the changes made by a user project.

The resultant Word document looks as follows.

Word document after rejecting changes made by a user
Word document after rejecting changes made by a user

Similarly, you can filter the insert and delete revisions made by an author or all authors and accept the filtered changes in a Word document. You can get more information on this from the documentation.

GitHub repository

For more information, refer to the complete, working example of reviewing a Word document.

Conclusion

With the help of the comments and track changes functionalities, you can provide reviewing capability for a Word document in your web application with ease.

Take a moment to peruse the documentation, where you’ll find other options and features, all with accompanying code examples. If you are new to our Word Processor (Document Editor), it is highly recommended that you follow our Getting Started guide.

Are you already a Syncfusion user? You can download the product setup here. If you’re not yet a Syncfusion user, you can download a free, 30-day trial here.

If you have any questions about these features, please let us know in the comments below. You can also contact us through our support forum, support portal, or feedback portal. We are happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed