Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (155).NET Core  (27).NET MAUI  (11)Angular  (51)ASP.NET  (48)ASP.NET Core  (68)ASP.NET MVC  (88)Azure  (29)Blazor  (114)DocIO  (21)Essential JS 2  (73)Essential Studio  (166)File Formats  (22)Flutter  (117)JavaScript  (153)Microsoft  (104)PDF  (59)React  (35)Succinctly series  (124)Syncfusion  (505)TypeScript  (30)Uno Platform  (3)UWP  (4)Vue  (28)Webinar  (27)Windows Forms  (57)WinUI  (33)WPF  (127)Xamarin  (134)XlsIO  (24)Other CategoriesBarcode  (4)BI  (29)Bold BI  (4)Build conference  (6)Business intelligence  (53)Button  (4)C#  (111)Chart  (54)Cloud  (10)Company  (445)Dashboard  (6)Data Science  (3)Data Validation  (5)DataGrid  (51)Development  (273)Doc  (7)DockingManager  (1)eBook  (94)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (21)Extensions  (16)File Manager  (4)Gantt  (9)Gauge  (8)Git  (4)Grid  (27)HTML  (9)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (246)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (26)Performance  (7)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (6)Road Map  (9)Scheduler  (30)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (19)Solution Services  (2)Spreadsheet  (11)SQL  (7)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (11)Tips and Tricks  (71)UI  (149)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (1)Visual Studio  (23)Visual Studio Code  (13)Web  (237)What's new  (159)Windows 8  (19)Windows App  (1)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin
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:

·        ASP.NET Core

·        ASP.NET MVC

·        Java

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

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:

Share on twitter
Share on facebook
Share on linkedin
Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top