Skip to content

IGR_Text_Compare_Documents

Compares two documents and returns an enumerator for iterating through the differences.

Prototype

IGR_RETURN_CODE IGR_Text_Compare_Documents(
    const struct IGR_Text_Compare_Document_Source* doc1,
    const struct IGR_Text_Compare_Document_Source* doc2,
    const struct IGR_Text_Compare_Settings* settings,
    IGR_HTEXTCOMPARE* enumerator,
    Error_Control_Block* error
)

Parameters

doc1: Pointer to IGR_Text_Compare_Document_Source

The first document to compare.

doc2: Pointer to IGR_Text_Compare_Document_Source

The second document to compare.

settings: Pointer to IGR_Text_Compare_Settings

Settings for text comparison.

enumerator: Pointer to IGR_HTEXTCOMPARE

Pointer to store the enumerator for iterating through differences.

error: Pointer to Error_Control_Block

Contains any error text.

Return value

Success: IGR_LONG

Returns IGR_OK.

Failure: IGR_LONG

Returns one of the possible IGR_E error codes.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <string>
#include "DocumentFiltersObjects.h"

int main() {
    try {
        // Create a DocumentFilters object (Api is an alias for DocumentFilters)
        Hyland::DocFilters::Api api;

        // Initialize the DocumentFilters object
        api.Initialize("License Code", ".");

        // Open the documents using OpenExtractor in Paginated mode
        Hyland::DocFilters::Extractor doc1 = api.OpenExtractor("original.docx", Hyland::DocFilters::OpenMode::Paginated);
        Hyland::DocFilters::Extractor doc2 = api.OpenExtractor("revision.docx", Hyland::DocFilters::OpenMode::Paginated);

        // Compare the documents
        Hyland::DocFilters::CompareResults compare = doc1.Compare(doc2);

        // Iterate through the differences
        while (compare.MoveNext()) {
            Hyland::DocFilters::CompareResultDifference diff = compare.getCurrent(); 

            // Work with the diff object
            // ... Your code to process the differences goes here ...

            // Example: Print the type and text of the difference
            std::wcout << L"Difference Type: " << (int)diff.getType() << std::endl;
            std::wcout << L"Difference Text: " << diff.getText() << std::endl;
        }

        // Close the documents (not explicitly shown in the C# sample, but good practice)
        doc1.Close(); 
        doc2.Close(); 

    } catch (const std::exception& ex) {
        std::cerr << "Error: " << ex.what() << std::endl;
        return 1; // Indicate an error occurred
    }

    return 0;
}

See Also