-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
99 lines (89 loc) · 2.56 KB
/
check.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
if (isCgi())
$echo = "echoCGI"; // HTML output
else
$echo = "echoCLI"; // Text output
ReadMICR("C:/Users/Adi/Documents/Automation Anywhere Files/Automation Anywhere/My Tasks/onboarding specialist - BMC\OCR Images\check.tif", 1);
function ReadMICR($fileName, $page)
{
global $echo;
$echo ("MICR in FILE: " . $fileName . "\n");
try{
// Create reader
$reader = new COM("ClearMicr.CcMicrReader");
// Set options as needed
$emrfEnforceAbaParsing = 16;
$emrfExtendedMicrSearch = 07;
$reader->Flags = $emrfEnforceAbaParsing;
$reader->Flags |= $emrfExtendedMicrSearch;
$echo(sprintf("\nhi"));
// Open image
$reader->Image->Open($fileName, $page);
// Read Barcode
$cnt = $reader->FindMICR();
// Process results
for ($idx=1; $idx<=$cnt; $idx++)
{
$micr = $reader->MicrLine($idx);
$echo(sprintf("\nDocument: %s DPI: %4.1f\n", $micr->DocumentType, $micr->Dpi));
DisplayMicrInfo($micr->Info);
DisplayMicrInfo($micr->Routing);
DisplayMicrInfo($micr->RoutingChecksum);
$echo(sprintf("ABA Routing Number: %s%s\n", $micr->Routing->TextANSI, $micr->RoutingChecksum->TextANSI));
DisplayMicrInfo($micr->AuxOnUs);
DisplayMicrInfo($micr->EPC);
DisplayMicrInfo($micr->OnUs);
DisplayMicrInfo($micr->Amount);
DisplayMicrInfo($micr->Account);
DisplayMicrInfo($micr->CheckNumber);
// DisplayCharacters($micr);
}
}
catch (Exception $e) {
$echo("\n" . "Exceptiom in line " . $e->getLine());
$echo("\n" . $e->getMessage() . "\n");
$echo("\n" . $e->getTraceAsString() . "\n");
}
}
function DisplayMicrInfo($info)
{
global $echo;
if (!$info->IsRead) return;
$echo(sprintf("%-15s %s conf: %6.2f%% '%s' \n",
$info->Name, $info->IsAbaCompliant ? "ABA" : " ", $info->Conf,
$info->TextANSI));
}
function DisplayCharacters($micr)
{
global $echo;
$echo(sprintf("\n pos chr conf(%%) altchr conf(%%) dif(%%) \n"));
$emftChr = 182; $emftChrAlt = 184;
$var0 = new VARIANT(0);
for ($pos = 1; $pos < 1000; $pos++)
{
$chr = $micr->GetObject($emftChr, $pos, $var0);
$altchr = $micr->GetObject($emftChrAlt, $pos, $var0);
if ($chr == NULL) break;
$echo(sprintf(" %-3d %-2s %6.1f %-2s %6.1f %6.1f\n", $pos,
$chr->TextANSI, $chr->Conf,
$altchr->TextANSI, $altchr->Conf,
$chr->Conf - $altchr->Conf));
}
}
function echoCGI($sin)
{
echo "<font face='Courier'>";
$sout = str_replace(" ", " ", $sin);
$sout = nl2br($sout);
echo $sout;
echo "</font>";
}
function echoCLI($sin)
{
echo $sin;
}
function isCgi()
{
return !empty($_SERVER['GATEWAY_INTERFACE']);
}
?>