Based on your reply including 2 videos to explain our 2 scenarios. Let me know if you need any additional detail or files?
Scenario1-Disable coloring-mp4.zip (2.2 MB)
Scenario2-Show only latest diff-mp4.zip (2.3 MB)
Will you let me know if both scenarios can be possible?
1 Like
@qlnsubhash
Thanks for the details. We’ll now look into these scenarios. You’ll be notified in case of any update.
@qlnsubhash
For the First scenario :
You can change the styles of inserted/deleted components at your own discretion by providing StyleSettings in CompareOptions.
Code example for your case:
StyleSettings styleSettings = new StyleSettings() { FontColor = Color.Black };
CompareOptions compareOptions = new CompareOptions
{
DeletedItemStyle = styleSettings,
InsertedItemStyle = styleSettings,
};
See result-first-scenario.docx document in files.zip.
For the second scenario:
You can use the ApplyChangeOptions Accept or Reject detected changes
So if you REJECT the INSERTED change, it will be removed from the result file. And if you ACCEPT the DELETED change, it will be also deleted from the result file.
But the problem with your documents is that the “More text from Source. Additional text“ will be presented as ONE deleted change (paragraph) so you could only accept/reject the whole paragraph because words are in the same line.
As a workaround you can separate “More text from Source. Additional text“ by moving “Additional text“ on the next line so it will be presented as a new paragraph and you could reject/accept it without problems.
For your case i used the following code to get the attached result file:
SaveOptions saveOptions = new SaveOptions();
CompareOptions compareOptions = new CompareOptions
{
DetalisationLevel = DetalisationLevel.High,
};
Comparer comparer = new Comparer(sourcePath);
comparer.Add(targetPath);
comparer.Compare(String.Empty, saveOptions, compareOptions);
ChangeInfo[] changes = comparer.GetChanges();
List<ChangeInfo> newchanges = new List<ChangeInfo>();
foreach (ChangeInfo change in changes)
{
if (change.Text == "More text from Source.")
{
change.ComparisonAction = ComparisonAction.Accept;
}
if (change.Text == "This is entity specific changes")
{
change.ComparisonAction = ComparisonAction.Reject;
}
newchanges.Add(change);
}
comparer.ApplyChanges(File.Create(resultPath), new SaveOptions(), new ApplyChangeOptions { Changes = newchanges.ToArray() });
See target-second-scenario.docx, source-second-scenario.docx, result-second-scenario.docx documents - files.zip (44.3 KB).