Quickstart

This section demonstrates the use of the API with minimal input.

Input:

main.cpp, total0.yml, CSDK binaries + headers (FormProcEngine.dll, FormProcAPI.h)

Command:

cl.exe (from Visual Studio), main.exe (to be compiled)

Output:

Receipt_total0_0.json

The content of total0.ym is the following:

---
# Minimal example how to find set of words
title: totals
lang: en-US

fields:
- id: amount-anchor
  rules:
  - {voc: ['SUBTOTAL', 'TOTAL', 'AMOUNT']}

...

This finds the following words with or without punctuation:

  • Subtotal

  • Total

  • Amount

This is not case sensitive because all letters are capitalized. For non-strict case matching, see the OPFD specification document.

Compile a C code example

The provided main.cpp C code demonstrates the use of FormProcEngine.dll:

#include "FormProcAPI.h"
#include <stdio.h>

int main(int argc, char* argv[])
{
	int rc = OPFP_Init(NULL, NULL, 3);
	if (rc != 0) {
		printf("OPFP_Init failed with %d\n", rc);
		return rc;
	}

	const char *OPFDs[] = {"total0.yml", NULL};
	rc = OPFP_ProcessA("Receipt.fp", ".", OPFDs, "en-US");

	printf("OPFP_Process exited with %d\n", rc);

	OPFP_Quit();
	return rc;
}

To compile it, do the following:

  1. Open a Visual Studio command prompt (from where you can run cl.exe) and change directory to this guide.

  2. Locate FormProcEngine.lib and the directory of FormProcAPI.h and substitute their paths accordingly:

    > cl main.cpp C:\CSDK\MAIN\Development\lib64.rel\FormProcEngine.lib /I C:\CSDK\MAIN\Development\Tools\FormProcessor
  3. To stay in the directory of sample code with the given example .fp input and a writeable output, set the .exe file to run where the CSDK binaries located (including FormProcEngine.dll):

    > set PATH=%PATH%;C:\CSDK\MAIN\Development\bin64.rel
    It is up to the user application how the FormProcEngine.dll is located (with its dependencies like KernelAPI.dll).
  4. Run main.exe:

    > main.exe
    OPFP_Process exited with 0
    

    The Receipt_total0_0.json output file is generated including the following matches under fields.

    To prevent errors, remove this output file or clear its read-only attribute before running the executable.
        "fields": [
            {
                "id": "amount-anchor",
                "matches": [
                    {
                        "text": "Subtotal",
                        "properties": { "box": { "left": 43, "top": 1379, …} },
    			…
                    },
                    {
                        "text": "Total",
                        "properties": { "box": { "left": 44, "top": 1579, …} },
    			…
                    }
    	    ]
    }
        ],
    

Switch to the prepared FormProcApp.exe included in the CSDK binaries for demonstrating further individual examples:

guide> C:\CSDK\MAIN\Development\bin64.rel\FormProcApp.exe Receipt.fp . total0.yml -l en-US

OmniPage Form Processor Driver and Utility Tool v1.0
CSDK rootpath: ./
Processing... return 0 

The same Receipt_total0_0.json output file has been generated as with main.cpp. A difference with FormProcApp.exe is that it is prepared to accept a whole directory with many .fp files instead of just a single Receipt.fp. The API function OPFP_Process accepts only a single .fp file as an input. This .fp file that can have one or more pages.

The output file name is automatically determined inside OPFP_Process call:

Receipt_total0_0.json:
	<input basename>_<OPFD basename>_<page>.json
input basename: Receipt.fp => Receipt
OPFD basename: total0.yml => total0
page: 0-based index of the page

It is recommended to create a separate output directory for storing results. In the following examples, we work in current directory and with single input .fp.