Hi, I am using this code to compare 2 documents.
try (Comparer comparer = new Comparer(“./src/main/resources/doc_v1.docx”)) {
comparer.add(“./src/main/resources/doc_v2.docx”);
comparer.compare(“Output.docx”);
}
It’s not able to identify every new change in a new document as Aspose did. Do Aspose and GroupDocs use the same code to compare 2 documents?
@munish.singla
It seems that you are experiencing issues with the document comparison functionality in your code. The code snippet you provided is correctly structured for comparing two documents using the GroupDocs.Comparison library. However, if you are not seeing all the changes detected as expected, there are a few things you might want to consider:
-
Comparison Settings: GroupDocs.Comparison allows you to customize the comparison settings. You can specify options such as how to handle inserted or deleted items. For example, you can use the CompareOptions
class to set styles for inserted items, which might help in visualizing changes better.
Here’s an example of how to implement custom comparison settings:
CompareOptions compareOptions = new CompareOptions();
compareOptions.setInsertedItemStyle(new StyleSettings() {
{
setFontColor(Color.RED);
setIsUnderline(true);
}
});
comparer.compare("Output.docx", compareOptions);
-
Document Formats: Ensure that the documents you are comparing are in compatible formats. GroupDocs.Comparison supports various formats, but discrepancies in formatting or structure between different document types can affect the comparison results.
-
Library Versions: Check if you are using the latest version of the GroupDocs.Comparison library. Updates often include bug fixes and improvements that could enhance the comparison functionality.
-
Aspose vs. GroupDocs: While both libraries are designed for document manipulation, they may have different underlying algorithms and capabilities for comparison. If you are looking for specific features that Aspose offers, it might be worth checking their documentation or forums for more tailored solutions.
If you continue to face issues, consider providing more details about the specific changes that are not being detected, as this could help in diagnosing the problem further.
For more examples and detailed usage, you can refer to the GroupDocs.Comparison documentation and examples available on their GitHub repository.
Sources:
[1]: HelloWorld.cs
[2]: CompareDocumentsSettingsStream.cs