How can I read the insertions or deletions in a Document Revision?

using FileStream documentStream = new FileStream("1.docx", FileMode.Open, FileAccess.Read);
using WordDocument document = new WordDocument(documentStream, FormatType.Docx);

foreach (Revision revision in document.Revisions)
{
Console.WriteLine($"Revision Type: {revision.RevisionType}");
Console.WriteLine($"Author: {revision.Author}");
Console.WriteLine($"Date: {revision.Date}");
Console.WriteLine($"Revision Type: {revision.RevisionType}");
}


How can I read the words the revision is inserting or deleting? Thank you


11 Replies

DS Dharanya Sakthivel Syncfusion Team August 30, 2024 08:22 AM UTC

Robert,

Based on the given details, we understood that you want to read the words that are inserted or deleted in a revision within a Word document. To achieve this, we have prepared and attached the sample in the below attachment.

In the attached sample, we identify the inserted and deleted text ranges by using the Boolean properties
IsInsertRevision and IsDeleteRevision. The sample then reads and prints the text to the console.

Regards,
Dharanya.



Attachment: Readinsertiondeletioninrevision_5aeca7cb.zip


RM Robert Muresan September 3, 2024 08:06 PM UTC

I see the amount of textRanges where IsInsertRevision is true is not equal to the revisions where RevisionType is Insertion.


Given an insertion revision, how can I get the textRanges associated with that specific revision? I need to know this information so I can accept only certain revisions.



DS Dharanya Sakthivel Syncfusion Team September 4, 2024 02:22 PM UTC

Robert, based on the given details, we understand that you are looking to accept specific revisions based on the textRanges associated with insertion revisions. We will analyze this and share the details with you the day after tomorrow.

In the meantime, kindly share more details about your complete requirement. This will help us ensure we address everything you need.

Regards,
Dharanya.



RM Robert Muresan September 6, 2024 02:34 AM UTC

Given a specific Revision, I want to know all the text ranges associated with it. 

By reading those specific text ranges, I need to decide whether to accept or reject the revision.


Thank you!



DA Dharanitharan Ayyasamy Syncfusion Team September 6, 2024 12:04 PM UTC

Thanks for providing the clear details about the requirement. Currently we are analyzing this with high priority, we will update further details on two days.



DA Dharanitharan Ayyasamy Syncfusion Team September 9, 2024 10:32 AM UTC

Robert,

From the provided details, we have found that your end requirement is to identify the track changes like insertion, deletion of each content and need to take accept or reject decisions based on that content in the input Word document. It is like reviewing the entire Word document and accepting or rejecting the
changes.

For this requirement we suggest you to use our Word document editor control, where you can be able to load an existing Word document containing track changes and make the required decisions. For example, the track changes in the existing Word document will be shown as below,

From the right-side pane you can be able to accept or reject the entire contents as like in the MS Word document.

In addition to this, you can be able to do track the changes in document editor control itself.

Doing the above UI related requirement using our non UI Syncfusion DocIO library with back-end logics will results in implementing more sample level logics in your application. So, we are suggesting you to use the Document editor control.

Online working demo: ASP.NET Core DocumentEditor Track Changes Example - Syncfusion Demos
UG Documentation : Getting Started with Syncfusion ASP.NET CORE Document Editor Control

If the above suggestions are not helpful for you, kindly let us know complete work flow of your application (why you are trying to automate the Word document reviewing process programmatically in C# instead of review like Microsoft Word). For example: Whether your workflow is to accept or reject (maintain as predefined method), if insertion applied to particular text in given Word documents from your customers document?



RM Robert Muresan September 10, 2024 12:12 AM UTC

I need this to happen programmatically in the backend.


Here is an example workflow:

I want to only accept revisions where the text range is an insertion adding the text "HELLO".

So I want to look through each revision, and only accept those that meet this criteria, and deny others.


The reason I need this:

I am generating a filled in template, using docxtemplater, given a ton of data. Lets call this generated template Document A.

The user is able to edit this template. Lets call this user edited template Document B. To see the manual changes by the user, I am comparing Document A and Document B (using document.Compare). This outputs a list of revisions, representing the manual changes the user made.


There are instances where I regenerate this template, for example because the data has been changed; this potentially adds rows to tables and text changes in the document. Let's call this regenerated template Document C.

I now compare Document C and Document B. I want to accept every revision seen in both comparisons, thus applying the manual changes made in Document B to Document C.


Do you need any more context on my workflow. I just need to be able to read the text ranges for a specific revision.


Thank you,

Robert



DA Dharanitharan Ayyasamy Syncfusion Team September 10, 2024 02:50 PM UTC

Robert, thanks for providing the clear details about the requirement. Currently we are analyzing this with high priority, we will update further details on two days.



DA Dharanitharan Ayyasamy Syncfusion Team September 12, 2024 02:32 PM UTC

Robert, currently our DocIO library does not support to get text from track changes revision. We have considered this requirement as a feature request for "Support to get text from revision of track changes" in our database. Currently, we do not have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all the open features. We will let you know once this feature is implemented.

The status of this feature can be tracked through the
feedback link.



RM Robert Muresan September 12, 2024 02:47 PM UTC

Is there any hacky way for me to implement this myself? I need this functionality.



DS Dharanya Sakthivel Syncfusion Team September 13, 2024 02:18 PM UTC

Robert,

Currently, there is no workaround solution to achieve your requirement. As mentioned in our initial update, you can use the Boolean properties
IsInsertRevision and IsDeleteRevision to identify the text ranges for insertions and deletions. Based on the author’s name or revision type, you can then choose to accept or reject these revisions.

Please refer to the below links for further details.
Accepting-or-rejecting-track-changes-by-a-particular-reviewer
How-to-enable-track-changes-for-word-document

Regards,
Dharanya.



Loader.
Up arrow icon