Review Word Documents with Track Changes and Comments in a Web Application
Tags: blazor, webdev, javascript, angular
Published: 2021-12-10 12:12:03

---
title: Review Word Documents with Track Changes and Comments in a Web Application
published: true
date: 2021-12-10 11:00:50 UTC
tags: blazor, webdev, javascript, angular
canonical_url: https://www.syncfusion.com/blogs/post/review-word-documents-track-changes-and-comments-in-web-application.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9o5sra5wteis5syr8mr.png
---

In this blog, we are going to see how easy it is to review a Word document using [Syncfusion’s Word framework](https://www.syncfusion.com/word-framework/net "Link to .NET 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)](https://www.syncfusion.com/javascript-ui-controls/js-word-processor "Link to JavaScript Word Processor") 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](https://www.syncfusion.com/javascript-ui-controls/js-word-processor "Link to JavaScript Word Processor") (ES5 and ES6), [Angular](https://www.syncfusion.com/angular-ui-components/angular-word-processor "Link to Angular Word Processor"), [React](https://www.syncfusion.com/react-ui-components/react-word-processor "Link to React Word Processor"), [Vue](https://www.syncfusion.com/vue-ui-components/vue-word-processor "Link to Vue Word Processor"), [ASP.NET MVC](https://www.syncfusion.com/aspnet-mvc-ui-controls/word-processor "Link to ASP.NET MVC Word Processor"), [ASP.NET Core](https://www.syncfusion.com/aspnet-core-ui-controls/word-processor "Link to ASP.NET Core Word Processor"), and [Blazor](https://www.syncfusion.com/blazor-components/blazor-word-processor "Link to Blazor Word Processor") platforms.

<table>
<tbody>
<tr>
<td width="601"><strong>Note:</strong> 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:

·        <a title="Documentation link to Using ASP.NET Core in JavaScript DocumentEditor control" href="https://ej2.syncfusion.com/documentation/document-editor/web-services/core/">ASP.NET Core</a>

·        <a title="Documentation link to Using ASP.NET MVC in JavaScript DocumentEditor control" href="https://ej2.syncfusion.com/documentation/document-editor/web-services/mvc/">ASP.NET MVC</a>

·        <a title="Documentation link to Using Java in JavaScript DocumentEditor control" href="https://ej2.syncfusion.com/documentation/document-editor/web-services/java/">Java</a>

You can find the web API projects for the supported platforms in this <a title="GitHub demo link for Document Editor Web services" href="https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices">GitHub repository</a>.</td>
</tr>
</tbody>
</table>

## 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](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/#enablecomment "Link to the enableComment property of JavaScript Document Editor") 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](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/#currentuser "Link to the currentUser property of JavaScript Document Editor") property.

![Document editor component with comments](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/Document-editor-component-with-comments.png)
<figcaption>Document editor component with comments</figcaption>

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](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/Posting-or-discarding-a-comment.png)
<figcaption>Posting or discarding a comment</figcaption>

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](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/The-edit-delete-reply-and-resolve-options-of-a-comment.png)
<figcaption>The edit, delete, reply, and resolve options of a comment</figcaption>

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](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/Enabling-track-changes-in-Document-Editor.png)
<figcaption>Enabling track changes in Document Editor</figcaption>

![Options for viewing, accepting, or rejecting tracked changes](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/Options-for-viewing-accepting-or-rejecting-tracked-changes.png)
<figcaption>Options for viewing, accepting, or rejecting tracked changes</figcaption>

### Accept or reject changes

Syncfusion provides a comprehensive [Word Library](https://www.syncfusion.com/word-framework/net/word-library "Link to .NET 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)](https://help.syncfusion.com/cr/file-formats/Syncfusion.DocIO.DLS.WordDocument.html#Syncfusion_DocIO_DLS_WordDocument_Revisions "Link to the Revisions property of .NET Word Library") 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](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/Tracked-changes-in-a-Word-document.png)
<figcaption>Tracked changes in a Word document</figcaption>

#### 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.

```csharp
//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](https://github.com/SyncfusionExamples/Review-Word-documents-in-Web-application/tree/main/Server-side/Accept-all-changes-made-by-an-author "GitHub demo link for accepting all changes made by an author in Document Editor") project sample.

The resultant Word document looks as follows.

![Word document after accepting changes made by a user](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/Word-document-after-accepting-changes-made-by-a-user.png)
<figcaption>Word document after accepting changes made by a user</figcaption>

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.

```csharp
//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](https://github.com/SyncfusionExamples/Review-Word-documents-in-Web-application/tree/main/Server-side/Reject-insert-delete-revisions-made-by-all-authors "GitHub demo link for rejecting all revisions made by all authors in Document Editor") project.

The resultant Word document looks as follows.

![Word document after rejecting changes made by a user](https://www.syncfusion.com/blogs/wp-content/uploads/2021/12/Word-document-after-rejecting-changes-made-by-a-user.png)
<figcaption>Word document after rejecting changes made by a user</figcaption>

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](https://help.syncfusion.com/file-formats/docio/accepting-or-rejecting-track-changes "Documentation link to Accepting or Rejecting Track Changes in Document Editor").

## GitHub repository

For more information, refer to the complete, working [example of reviewing a Word document](https://github.com/SyncfusionExamples/Review-Word-documents-in-Web-application "GitHub demo link for reviewing word documents with track changes and comments in web application").

## 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](https://ej2.syncfusion.com/documentation/document-editor/track-changes/ "Documentation link to Track Changes in JavaScript DocumentEditor control"), 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](https://ej2.syncfusion.com/documentation/document-editor/getting-started/ "Documentation link to getting started with JavaScript DocumentEditor control").

Are you already a Syncfusion user? You can download the product setup [here](https://www.syncfusion.com/account/downloads/studio/ "Link to license and download page of Essential Studio"). If you’re not yet a Syncfusion user, you can download a free, 30-day trial [here](https://www.syncfusion.com/downloads/fileformats/confirm "Link to the free evaluation of the Syncfusion Essential Studio for File Formats").

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](https://www.syncfusion.com/forums/ "Link to the Syncfusion support forum"), [support portal](https://support.syncfusion.com/ "Link to the Syncfusion support portal"), or [feedback portal](https://www.syncfusion.com/feedback/word "Link to Syncfusion Feedback Portal"). We are happy to assist you!

## Related blogs

- [How to Dynamically Fill Data in Word Table Using Java](https://dev.to/karthickramasamy08/how-to-dynamically-fill-data-in-word-table-using-java-6mg-temp-slug-8509031 "Link to How to Dynamically Fill Data in Word Table Using Java blog")
- [Create and Update Table of Contents in Word Documents in .NET Core [C#]](https://dev.to/syncfusion/create-and-update-table-of-contents-in-word-documents-in-net-core-c-4o0j "Link to Create and Update Table of Contents in Word Documents in .NET Core [C#] blog")
- [Find and Replace Text in a Word Document Using C#](https://dev.to/syncfusion/7-useful-ways-to-find-and-replace-text-in-a-word-document-using-c-4j0c "Link to Find and Replace Text in a Word Document Using C# blog")
- [Mail Merge in Word Documents Using C# and VB.NET: The Ultimate Guide](https://dev.to/syncfusion/mail-merge-in-word-documents-using-c-and-vb-net-the-ultimate-guide-5hee "Link to Mail Merge in Word Documents Using C# and VB.NET: The Ultimate Guide blog")