06-09-2009 12:02 PM
<?php
class files_object{
public $FileName;
public $FileContents;
}
class ProcessFile{
public $location = "ogre.co.dac.int";
public $workflowName;
public $file;
};
if ($argv[1]=="–help"||$argv[1]=="-h") {
print "Usage: php ocr.php <source file> <destination file> <ocr workflow name>\n";
return 0;
} else {
$input_file_name = $argv[1];
$output_file_name = $argv[2];
$workflow = $argv[3];
if (is_null($input_file_name) || is_null($output_file_name) || is_null($workflow) ) {
print "Usage: php ocr.php <source file> <destination file> <ocr workflow name>\n";
return 2;
}
if(!file_exists($input_file_name) || !is_readable($input_file_name)) {
print "Input file cannot be read or does not exist. Exiting.\n";
return 2;
} else {
$input_filehandle = fopen($input_file_name, "r");
$input_file_content = fread($input_filehandle, filesize($input_file_name));
fclose($input_filehandle);
$file = new files_object;
$file->FileName = basename($input_file_name);
$file->FileContents = $input_file_content;
$soap_process = new ProcessFile;
$soap_process->workflowName = $workflow;
$soap_process->file = $file;
$client = new SoapClient("http://ogre.co.dac.int/RecognitionWS/RSSoapService.asmx?wsdl");
$results = $client->ProcessFile($soap_process);
$content = $results->ProcessFileResult->InputFiles->InputFile->OutputDocuments->OutputDocument->Files->FileContainer->FileContents;
$name = $results->ProcessFileResult->InputFiles->InputFile->OutputDocuments->OutputDocument->Files->FileContainer->FileName;
$output_filehandle = fopen($output_file_name, "w");
fwrite($output_filehandle, $content);
fclose($output_filehandle);
}
}
?>
php ocr.php {source file} {target file} {workflow name}
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="transformer.TIFF.OCR" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer" parent="baseContentTransformer">
<property name="transformCommand">
<bean class="org.alfresco.util.exec.RuntimeExec">
<property name="commandMap">
<map>
<entry key="Linux">
<value>php /srv/alfresco/bin/ocr.php ${source} ${target} OCRtoPDF</value>
</entry>
</map>
</property>
</bean>
</property>
<property name="explicitTransformations">
<list>
<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
<property name="sourceMimetype"><value>image/tiff</value></property>
<property name="targetMimetype"><value>application/pdf</value></property>
</bean>
</list>
</property>
</bean>
<bean id="transformer.TIFF.TXT" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer" parent="baseContentTransformer">
<property name="transformCommand">
<bean class="org.alfresco.util.exec.RuntimeExec">
<property name="commandMap">
<map>
<entry key="Linux">
<value>php /srv/alfresco/bin/ocr.php ${source} ${target} OCRtoTXT</value>
</entry>
</map>
</property>
</bean>
</property>
<property name="explicitTransformations">
<list>
<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
<property name="sourceMimetype"><value>image/tiff</value></property>
<property name="targetMimetype"><value>text/plain</value></property>
</bean>
</list>
</property>
</bean>
</beans>
10-05-2010 03:27 AM
08-01-2012 10:47 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.