priyaviswam has asked for the wisdom of the Perl Monks concerning the following question:
Please tell me how can I find that the object $miDoc has not text content. So that I can avoid this crash.sub ApplyOCR{ my $TiffImageLocation = $_[0]; my $LogFilePath = $_[1]; if (-f $LogFilePath){ unlink $LogFilePath; } Win32::OLE::Const->Load("Microsoft Office Document Imaging 12\.0 T +ype Library") or die "Cannot use the Office 2007 OCR API"; my $miDoc = Win32::OLE->new('MODI.Document') or die "Cannot creat +e a MODI object"; $miDoc->Create("$TiffImageLocation"); $miDoc->OCR(9,1,1); my $OCRResult = $miDoc->{Images}->Item(0)->{Layout}{Text}; open (LOG, ">>$LogFilePath") or die $!; if ($Image){ print LOG "Image Name : $Image\n"; print LOG "==========\n\n"; } print LOG "OCRResult : \n"; print LOG "$OCRResult\n\n"; close LOG; }
|
|---|