Hello Atir,
- I am trying to compare MSWord_Template Horizontal Lines.zip (29.6 KB)
with TextControl_Template Horizontal Lines.zip (13.7 KB)
I am getting lots of changes for deletion of HeaderFooter.0001_GDResults_Template Horizontal Lines.zip (17.4 KB)
Can you please explain why are those entries coming?
- For this document comparison MSWord_Default CC Form.zip (11.8 KB)
with TextControl_Default CC Form.zip (5.4 KB)
the position alignment is changed DefaultCCForm.png (2.5 KB)
I think this resultset is not tracking it. 0001_GDResults_Default CC Form.zip (1.9 KB)
My code looks like:
public int CompareDocs(Stream doc1Stream, Stream doc2Stream, string customerFolder, string templateName, string counter)
{
string extension = Utility.GetFileExtension(doc1Stream);
string outputFileName = Path.Combine($"{ Constants._ComparisonDirectoryPath}{customerFolder}\{Constants._GDResultsDirectoryNameDocx}\", $"{counter}GDResults{templateName}.{extension}");
using (Comparer comparer = new Comparer(doc1Stream))
{
comparer.Add(doc2Stream);
CompareOptions compareOptions = new CompareOptions()
{
InsertedItemStyle = new StyleSettings()
{
HighlightColor = System.Drawing.Color.Yellow,
FontColor = System.Drawing.Color.DarkGreen,
IsUnderline = true,
IsBold = true,
IsStrikethrough = true,
IsItalic = true
},
DeletedItemStyle = new StyleSettings()
{
HighlightColor = System.Drawing.Color.LightGreen,
FontColor = System.Drawing.Color.DarkRed,
IsUnderline = true,
IsBold = true,
IsStrikethrough = true,
IsItalic = true
},
ChangedItemStyle = new StyleSettings()
{
HighlightColor = System.Drawing.Color.LightGray,
FontColor = System.Drawing.Color.DarkBlue,
IsUnderline = true,
IsBold = true,
IsStrikethrough = true,
IsItalic = true
},
GenerateSummaryPage = true,
ExtendedSummaryPage = true,
CompareVariableProperty = true,
//CompareDocumentProperty = true,
CompareBookmarks = true,
SensitivityOfComparison = 100,
HeaderFootersComparison = true,
CalculateCoordinates = true,
ShowDeletedContent = true,
DetalisationLevel = DetalisationLevel.High,
DetectStyleChanges = true,
MarkChangedContent = true,
MarkNestedContent = true,
ShowInsertedContent = true
};
string outputTextFileName = Path.Combine($"{ Constants._ComparisonDirectoryPath}{customerFolder}\\{Constants._GDResultsDirectoryNameTxt}\\", $"{counter}_GDResults_{templateName}.txt");
try
{
comparer.Compare(File.Create(outputFileName), compareOptions);
ChangeInfo[] changes = comparer.GetChanges();
string comparison = string.Empty;
foreach (var change in changes)
{
comparison += $"Change Type: { change.Type.ToString()} {Environment.NewLine} Change Text: {change.Text} {Environment.NewLine} Source Text {change.SourceText} {Environment.NewLine} Target Text {change.TargetText} {Environment.NewLine}";
comparison += $"Component Type: { change.ComponentType}, Change ComparisonAction: {change.ComparisonAction.ToString()},{Environment.NewLine}";
comparison += $"Change Box: X: { change.Box.X.ToString() }, Y: { change.Box.Y.ToString() }, Width: { change.Box.Width.ToString() }, Height: { change.Box.Height.ToString() } {Environment.NewLine}";
comparison += $"Page Info: Page number - { change.PageInfo.PageNumber }, Page Width: {change.PageInfo.Width}, Page Height: {change.PageInfo.Height}{Environment.NewLine}";
foreach (var styleChange in change.StyleChanges)
{
comparison += $"Property: { styleChange.PropertyName} - Old Value: { styleChange.OldValue } - New Value: {styleChange.NewValue} {Environment.NewLine}";
}
comparison += $"===================================================================={Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}";
}
File.WriteAllText(outputTextFileName, comparison);
}
catch(Exception ex)
{
log.Error($"Error in Convertint Document: {Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.ToString()}");
File.WriteAllText(outputTextFileName,
$"Error in Converting Document: {Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.ToString()}");
}
}
Console.WriteLine($"\nDocuments compared successfully.\nCheck output in {Directory.GetCurrentDirectory()}.");
return 1;
}
Thanks,
Varun