/// <summary> /// Start the comparison /// </summary> /// <returns></returns> public ChangeInfo[] Compare() { //Create new comparison comparison = new GroupDocs.Comparison.Comparison(); var resultName = Path.Combine(_settings.RootStoragePath, resultFileName); //Compare documents Stream stream = comparison.Compare(_source.Content, _target.Content, resultName, _settings.ComparisonBehavior, _target.Extention); //Get changes var changes = comparison.GetChanges(); //Cut changes and return return(changes.ToArray()); }
//ExEnd:CompareTextDcumentsFromStreamToFile //ExStart:CompareTextDcumentsFromPathToFile /// <summary> /// Compare two Text documents from file path with saving results into a file /// </summary> public static void CompareTextDcumentsFromPathToFile() { // Get instance of GroupDocs.Comparison.Comparison and call method Compare. GroupDocs.Comparison.Comparison comparison = Common.getComparison(); Stream result = comparison.Compare(Path.Combine(Common.sourcePath, Common.sourceFile), Path.Combine(Common.targetPath, Common.targetFile), Path.Combine(Common.resultPath, Common.resultFile), ComparisonType.Text); // get changes GroupDocs.Comparison.Common.Changes.ChangeInfo[] changeInfo = comparison.GetChanges(); foreach (GroupDocs.Comparison.Common.Changes.ChangeInfo change in changeInfo) { Console.WriteLine("Text: " + change.Text); // update change with custom text change.Text = "Added text by update change."; } Console.WriteLine("apply changes and display updated stream with changes."); // update changes result = comparison.UpdateChanges(changeInfo, FileType.Txt); }
//ExEnd:CompareWithAutomaticFormatDetectionFromPathWithSettingsAndType //ExStart:CompareWithAutomaticFormatDetectionFromPathToFileWithExtensionSettingsAndType /// <summary> /// Compare two documents from file path with automatic format detection with saving results into a file with comparison type and settings and file extension /// </summary> public static void CompareWithAutomaticFormatDetectionFromPathToFileWithExtensionSettingsAndType() { // Get instance of GroupDocs.Comparison.Comparison and call method Compare. GroupDocs.Comparison.Comparison comparison = Common.getComparison(); Stream result = comparison.Compare(Path.Combine(Common.sourcePath, Common.sourceFile), Path.Combine(Common.targetPath, Common.targetFile), Path.Combine(Common.resultPath, Common.resultFile), ComparisonType.Words, new WordsComparisonSettings(), FileType.Docx); // Get all changes GroupDocs.Comparison.Common.Changes.ChangeInfo[] changes = comparison.GetChanges(); if (changes != null) { foreach (GroupDocs.Comparison.Common.Changes.ChangeInfo change in changes) { Console.WriteLine("Page ID: " + change.Page.Id.ToString() + " Page Height:" + change.Page.Height.ToString() + " Width:" + change.Page.Width.ToString()); Console.WriteLine("Change Type: " + change.Type.ToString()); Console.WriteLine("Change Text: " + change.Text); // to get style changes //change.StyleChanges } } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
/// <summary> /// Start the comparison /// </summary> /// <returns></returns> public ChangeInfo[] Compare() { //Create new comparison comparison = new GroupDocs.Comparison.Comparison(); var resultName = Path.Combine(_settings.RootStoragePath, resultFileName); //Compare documents Stream stream = comparison.Compare(_source.Content, _target.Content, resultName, _settings.ComparisonBehavior, _target.Extention); //Get changes var changes = comparison.GetChanges(); //Cut changes and return return changes.ToArray(); }