Skip to content

IGR_Text_Compare_Pages

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

Prototype

IGR_RETURN_CODE IGR_Text_Compare_Pages(
    IGR_HPAGE page1,
    const struct IGR_FRect* page1_margins,
    IGR_HPAGE page2,
    const struct IGR_FRect* page2_margins,
    const struct IGR_Text_Compare_Settings* settings,
    IGR_HTEXTCOMPARE* enumerator,
    Error_Control_Block* error
)

Parameters

page1: IGR_HPAGE

The first page to compare.

page1_margins: Pointer to IGR_FRect

The margins of the first page.

page2: IGR_HPAGE

The second page to compare.

page2_margins: Pointer to IGR_FRect

The margins of the second page.

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
43
44
45
46
47
48
49
50
#include <DocumentFilters.h>
#include <string.h>
#include <string>

#define UCS2(src) reinterpret_cast<const IGR_UCS2 *>(std::u16string(src).c_str())

int main(int argc, char **argv)
{
    Instance_Status_Block isb = {0};
    Error_Control_Block ecb = {0};
    IGR_SHORT df;
    IGR_LONG caps, type, pageCount = 0;
    IGR_HDOC doc1_handle = 0, doc2_handle = 0; 
    IGR_HPAGE doc1_page1_handle = 0, doc2_page1_handle = 0;
    IGR_HTEXTCOMPARE compare = 0;

    strncpy(isb.Licensee_ID1, "License Code", sizeof(isb.Licensee_ID1) - 1);
    Init_Instance(0, ".", &isb, &df, &ecb);

    if ((res = IGR_Open_File_Ex(UCS2(u"original.doc"), IGR_FORMAT_IMAGE, UCS2(u""), &caps, &type, &doc1_handle, &ecb)) == IGR_OK
        && (res = IGR_Open_File_Ex(UCS2(u"revised.doc"), IGR_FORMAT_IMAGE, UCS2(u""), &caps, &type, &doc2_handle, &ecb)) == IGR_OK
        && (res = IGR_Open_Page(doc1_handle, 0, &doc1_page1_handle, &ecb)) == IGR_OK
        && (res = IGR_Open_Page(doc2_handle, 0, &doc2_page1_handle, &ecb)) == IGR_OK)
    {
        IGR_Text_Compare_Settings settings = { sizeof(IGR_Text_Compare_Settings) };
        IGR_Compare_Documents_Difference diff = { sizeof(IGR_Compare_Documents_Difference) };

        if ((ret = IGR_Text_Compare_Pages(doc1_page1_handle, nullptr, doc2_page1_handle, nullptr, &settings, &compare, &ecb)) == IGR_OK)
        {
            while (IGR_Text_Compare_Next(compare, &diff, &ecb) == IGR_OK)
            {
                // ... work with diff object

                IGR_Text_Compare_Difference_Dispose(&diff, &ecb);
            }

            IGR_Text_Compare_Close(compare, &ecb);
        }
    }

    if (doc1_page1_handle)
        IGR_Close_Page(doc1_page1_handle, &ecb);
    if (doc2_page1_handle)
        IGR_Close_Page(doc2_page1_handle, &ecb);
    if (doc1_handle)
        IGR_Close_File(doc1_handle, &ecb);
    if (doc2_handle)
        IGR_Close_File(doc2_handle, &ecb);
    return 0;
}

See Also