Reject Formatting Changes of Specific Font Type in Word Document using C# | Track Changes | Revisions

In Aspose.Word .NET - how to reject change revisions of specific font type. basically I need to remove specific font type changes from change revisions -

if(revisionType == Revision.FormatChange)
{
// I want to reject change revision having Bold Font type
}

@indeAspose,

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Aspose.Words 20.3 generated output DOCX file showing the undesired behavior (if any)
  • Your expected DOCX file showing the desired output. You can create this document by using MS Word. Please also list the complete steps that you performed in MS Word to create the expected document on your end
  • A screenshot that assists us to understand the scenario

As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you code to achieve the same by using Aspose.Words for .NET API. Thanks for your cooperation.

sample_UnwantedFormatting.zip (103.4 KB)

From attached doc, I need to reject all other formatting changes expect font change as bold , italics

@indeAspose,

I think, you can meet this requirement by using the following code:

Document doc = new Document("E:\\Temp\\sample_UnwantedFormatting\\sample.doc.docx");

ArrayList list = new ArrayList();
foreach (Revision rev in doc.Revisions)
{
    if (rev.RevisionType == RevisionType.FormatChange)
    {
        list.Add(rev);
    }
}

foreach (Revision rev in list)
{
    if (rev.ParentNode.NodeType == NodeType.Run &&
        ((Run)rev.ParentNode).Font.Bold)
    {

    }
    else
    {
        rev.Reject();
    }
}

doc.Save("E:\\temp\\sample_UnwantedFormatting\\20.4.docx");