Using WordCollection

The following example saves the position and value of all the captured words on an invoice.

If sEHIAPP = EHIConstants.INTERPRET_STRING Then

     Ret = m_EHIAPP.Subscribe(Me, "InvoiceInterpreted", "OnIterateWords")

ElseIf sEHIAPP = EHIConstants.VERIFY_STRING Then

     Ret = m_EHIAPP.Subscribe(Me, "InvoiceVerify", "OnIterateWords")

End If

Public Function OnIterateWords() As Long

    Dim fso As Scripting.FileSystemObject

    Set fso = New Scripting.FileSystemObject

    Dim out As TextStream

    Set out = fso.CreateTextFile("c:\data\words.txt")

    

    Dim info AsString

    Dim pageColl As InvoicePages

    Set pageColl = m_EHIAPP.CurrentInvoice.Pages

    Dim wordColl As Variant

    Dim word AsVariant

    Dim page AsInvoicePage

    For Each page In pageColl

        info = page.ImageFileName

        Set wordColl = page.WordCollection

        For Each word In wordColl

            out.Write word.Rect

            out.Write " -> "

            out.Write word.String

            out.WriteLine

        Next word

    Next page

    out.Close

    OnIterateWords = 0

End Function

The example above could create the following output, for example:

522, 229, 535, 314 -> l

554, 241, 735, 314 -> ex"

302, 444, 536, 498 -> .Quantity

558, 444, 610, 485 -> in

632, 442, 975, 486 -> Culture

997, 443, 1203, 496 -> Design!

1933, 151, 2055, 184 -> Mongart

2077, 151, 2125, 183 -> 14

1933, 210, 2127, 244 -> D-75239

2146, 209, 2310, 252 -> City

1933, 270, 2001, 303 -> Phone

2021, 269, 2114, 302 -> 072

2130, 268, 2185, 302 -> 32