After a lot of experimentation, I still cannot work with the following script. I need to be guided by how to diagnose this Perl problem. Thanks in advance.
This script is designed to test the use of the Office 2007 OCR API:
use warnings;
use strict;
use Win32::OLE;
use Win32::OLE::Const;
Win32::OLE::Const->Load("Microsoft Office Document Imaging 12\.0 Type Library")
or
die "Cannot use the Office 2007 OCR API";
my $miDoc = Win32::OLE->new('MODI.Document')
or die "Cannot create a MODI object";
$miDoc->Create('OCR-test.tif');
$miDoc->OCR(LangId => 'miLANG_ENGLISH');
my $OCRresult = $miDoc->{Images}->Item(0)->{Layout}{Text};
print $OCRresult;
I did a little test. I uploaded a .MDI file containing OCR information. I deleted the OCR method line and ran the script, and I got the expected output of the text "print $ OCRresult". But otherwise, Perl throws me a mistake saying
Use of uninitialized value $OCRresult in print at E:\OCR-test.pl line 15
I suspect something is wrong with the line
$miDoc->OCR(LangId => 'miLANG_ENGLISH');
, "miLANG_ENGLISH", 1,1 .., .
Microsfot Office Document Imaging, , TIF, , , .
, ?
-, , Office 2007 jpg, bmp tif, , - ?
.
UPDATE
-, , . @hobbs, , :) . , Office Document Imaging 2003 VBA Language Reference, . :
LangId can be one of the following MiLANGUAGES constants.
miLANG_CHINESE_SIMPLIFIED (2052, &H804)
OCR:
$miDoc->OCR('miLANG_ENGLISH',1,1);
:
$miDoc->OCR(2052,1,1);
:
1. ActivePerl 5.10.0 Windows XP ( )
2. $miDoc → (9),
, , " $OCRresult E:\OCR-test.pl 15" , OCRed. OCR , "2052" , TIF .
$ miDoc- > OCR (9,1,1), . Windows :
unknown software exception (0x0000000d)
TIF- , , "$ miDoc- > OCR (2052,1,1); , . .
, - API OCR Office 2007, -, Windows XP ( ) Office 2007, ,
$miDoc->OCR(9,1,1);
, , - : D