Ephesoft Com Wiki Developers Guide
Ephesoft Com Wiki Developers Guide
Ephesoft Com Wiki Developers Guide
Developers Guide
Contents [hide]
1 Ephesoft Script Guide
1.1 Batch Instance Group Feature
navigation 1.2 Force Review Feature
Wiki Home 1.3 ScriptAddNewTable.java
Ephesoft Home 1.4 ScriptAutomaticValidation.java
1.5 ScriptDocumentAssembler.java
download
1.6 ScriptExport.java
Community Edition
1.7 ScriptExtraction.java
documentation 1.8 ScriptFieldValueChange.java
Softw are 1.9 FunctionKey.java
Product Documentation 1.10 ScriptPageProcessing.java
How To 1.11 ScriptValidation.java
Admin Manual 2 Ephesoft Plugin Dev
User Manual 2.1 Creating Sample Plugin
Statistics 2.2 Advanced Implementation Steps
Developers Guide 2.3 Workflow Management
SDK JavaDoc 2.3.1 Introduction
support 2.3.2 XML Structure
Forums 2.3.3 Validation on above XML
Issue Tracking 2.3.4 Assumptions
3 Integrating External Applications with Ephesoft Validation
participate
3.1 How to use the External Application:
Forums
3.2 External Application and Security:
Feedback
3.3 Configuring the Title of External Applications through the admin UI
search 4 Scripting Changes in Version 2.5
5 JDOM Script Configuration
6 Netbeans IDE Setup
Go Search
7 Web Services API
toolbox 7.1 Authenticated client calls code sample
What links here 7.2 List of API’s exposed in Ephesoft Product
Related changes 7.2.1 Image Processing Web Service
Special pages 7.2.1.1 createSearchablePDF
Printable version 7.2.1.2 convertTiffToPdf
Permanent link 7.2.1.3 splitMultipageFile
7.2.1.4 createMultipageFile
7.2.2 Classification Web Service
7.2.2.1 classifyImage
7.2.2.2 classifyBarcodeImage
7.2.2.3 classifyHOCR
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
7.2.2.4 classifyMultiPageHOCR
7.2.3 Extraction Web Service
7.2.3.1 extractKV
7.2.3.2 extractFixedForm
7.2.3.3 extractFieldFromHocr
7.2.3.4 extractFuzzyDB
7.2.3.5 barcodeExtraction
7.2.3.6 regularRegexExtraction
7.2.3.7 commonAPIForExtraction
7.2.4 OCR Web Service
7.2.4.1 createOCR
7.2.5 Users and Groups Web Service
7.2.5.1 getBatchInstanceForRole
7.2.5.2 getBatchClassForRole:
7.2.6 Reporting Web Service
7.2.6.1 runReporting
7.2.7 Batch Instance Management Web Service
7.2.7.1 getBatchInstanceList
7.2.7.2 getAllModulesWorkflowNameByBatchClass
7.2.7.3 restartBatchInstance
7.2.7.4 deleteBatchInstance
7.2.7.5 restartAllBatchInstance
7.2.7.6 addUserRolesToBatchInstance
7.2.8 Batch Class Management Web Service
7.2.8.1 importBatchClass
7.2.8.2 exportBatchClass
7.2.8.3 getBatchClassList
7.2.8.4 getRoles
7.2.9 Uploading a Batch through a Web Service
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Method for assigning roles in batch instance group table:
public void assignedBatchInstanceGroup(String batchInstanceIdentifier, String userRole) throws DCMAException
Configurable parameters:
ScriptAddNewTable.java
The Add New Table script is useful for being able to generate a predefined table on the fly in the Validation view.
Example Scenario:
If you are processing invoice documents and have defined table extraction during the normal means, it is still possible that if the document is of poor image quality the table you have
defined for extraction may not be detected, or may be incomplete. In this case, you can use the Add New Table script to automatically generate a table for your invoice document type
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
with the click of a button. You could create a new empty table of your required structure, or even a populated one... using other extracted values from the documents fields to populate
the table values from a database table.
Example file: ScriptAddNewTable.java
ScriptAutomaticValidation.java
The Automatic Validation script is executed in the Ephesoft Batch Class work flow prior to reaching the Validation stage. This is the opportune time to implement any custom logic you
may require by running verification against the values that have been extracted for the fields defined.
Example Scenario:
You may wish you to retrieve the extracted value from one field, perhaps a Social Security Number, and use it to perform a look-up operation to an external database, retrieving an
associated name. You could then in turn us the results of these SQL query to populate the values of other document level fields defined in Ephesoft.
Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts
Example file: ScriptAutomaticValidation.java
ScriptDocumentAssembler.java
The Document Assembler script is executed in the Ephesoft Batch Class work flow following the Page Processing Module, and Prior to reaching the Document Review stage. At this
point the batch .xml has undergone Ephesoft's classification routines and the batch's contents are structured into documents, with confidence scores assigned. However, perhaps you
have a unique situation where the default Ephesoft classification behavior alone will not organize your batch's documents as your require. This script is the ideal location to implement
any logic to customize the classification organization of your batch. Although Document Level Fields are not yet present in the batch .xml at this point, page level fields are making
Script
Example Scenario:
You may be using cover sheets to aid in the classification accuracy for your documents. However by the time the work flow reaches the ScriptDocumentAssembler Ephesoft's
classification routines have already worked their magic and you may no longer have any use for the cover sheets. You can use this script to define some logic to remove the first page
of every document, which in this case would be the cover sheets.
We've provided as an example resource, a script that does exactly this: ScriptDocumentAssembler_remove-1st-page.java
ScriptExport.java
The Export script is executed in the Ephesoft Batch Class work flow during the processing of the Export Module. At this point all of Ephesoft's separation, classification, extraction, and
validation have been performed and the batch is in the process of leaving the Ephesoft system. Consequently, ScriptExport.java is the ideal place to implement logic facilitating custom
export requirements.
Example Scenario #1: As a batch is leaving the Ephesoft system, you may intend to import its .xml and image files into a document repository system. Your targeted system may
have its own internal XML schema for describing its contents, and to make the transition a seamless one you want to consider applying an XSLT translation to the Ephesoft batch .xml
so that it can be automatically imported and recognized by its destination system without manual effort.
Example Scenario #2: Perhaps you have a specific document management system such as FileBound in mind. FileBound uses Divider and Separator values to index its contents.
Ephesoft provides a FileBound Plugin in the Export Module. However, in addition to this you can implement logic in the ScriptExport.java file to populate the batch documents' divider
and separator fields based on a captured extraction value, barcode, or other means. Through Ephesoft scripting you could use an extracted barcode value as a look up key in a SQL
query to an external database table to retrieve the appropriate divider and separator values for a given document type.
Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts
Example file: ScriptExport.java
ScriptExtraction.java
The Extraction script, although similar in sequence position to the ScriptAutomaticValidation.java, is useful for the purpose of separating extraction from validation.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Example Scenario:
Assume you have some OMR field extraction defined to extract check boxes denoting credit card type. For example there could three boxes total, signifying a choice of visa, american
express, or mastercard. If filled out correctly the form should only have a check mark in one of the boxes. RecoStar OMR extraction will represent these three check boxes as a three
character string of binary values, with the box containing a mark being represented by a "1" value (the others, "0"). Your Extraction script function could analyze the binary values to
determine which of the three credit card vendors is being represented and set a document level field value to a string value of "visa", "amex", or "mastercard".
Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts
ScriptFieldValueChange.java
The Field Value Change script can be toggled through the Ephesoft Validation Module, and when enabled will fire when the value of a field is changed in the user Validation View. This
can be extremely useful if you want to have the changes you make to one field automatically produce a change in value of one or more other fields.
Example Scenario #1:
Consider the case where you have a field that is of the drop down list type. This field contains a list of various departments within an organization (eg: HR, IT, etc). In addition to this
field you have another drop down field that serves as a list of users. You can use the Field Change script to implement logic such that change the department value for field #1 will
automatically update the drop down list of field #2 with users that correspond to that newly selected department.
Example Scenario #2:
Perhaps you have had a document arrive in Validation View with a loan number field that has been extracted, and some corresponding fields that contain information related to the loan
number. However, consider if the loan number is incorrect, and your user manually needs to change it. Instead of having to also manually look up and change all of the corresponding
fields, the Field Change Value script could make it so that changing the Loan Number field value automatically performs a look up operation to a database and populates the additional
fields with the information on file for that loan number.
Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts
Example file: ScriptFieldValueChange.java
FunctionKey.java
The Function Key script allows for multiple methods to be defined within the FunctionKey.java and have these individual methods bound to keys on the users keyboard to act as
keyboard shortcuts for executing pieces of custom functionality.
Example Scenario:
Consider that you may have a default set of values for a given document type that you want the option to populate its fields with in Validation View at the push of a button. In
FunctionKey.java you would implement a method to set the fields of that document type to a set of default values. In the Ephesoft Validation Module you can define the Function Key
that you want to associate with this method. You must specify both the name of the function as well as the key that you wish you bind it to. Having done so you should now see the
Function Key that you specified as an icon in the Validation View. The custom function key method can now be invoked by clicking this button or striking the specified key itself.
Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts
Example file: ScriptFunctionKey.java
ScriptPageProcessing.java
The Page Processing script is useful for conducting operations on the XML representation of a batch's pages before they have undergone classification and encapsulation into
documents.
Example Scenario:
To reduce batch processing time it is possible to use ScriptPageProcessing to remove pages that are 'garbarge' and don't contain valid OCR data. You could implement a function that
would iterate through the collection of pages, and from each page element retrieve the corresponding OCR file (.html) and image file name. If the OCR data for the page is nonexistent,
and the original image size is below a certain threshold you can deem the page to be junk and remove it from the batch .xml. By removing these useless pages your batch will be able
to traverse the rest of the batch class workflow more efficiently and with an improved processing time.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts
ScriptValidation.java
The Validation script differs from the Automatic Validation script in that it is run during the user Validation User Interface experience, where as Automatic Validation executes and
performs custom validation steps immediately before the batch is presented to the user in the Validation UI. The benefit is this is that as the user is making changes to the document
field values in the Valdiation UI, the Validation Script can be triggered to run after each change to ensure that the changes are put through custom validation processing requirements.
Example Scenario:
You may have some a document level field, AccountNum, where the value being extracted should correspond to an existing account number in an external database. Perhaps due to
poor image quality, the OCR'd value for the account number is either incomplete or incorrect and so the document appears in Validation with its field highlighted in red. The user is able
to see the corresponding image and keys in what they believe to the the account number appearing on the image, but you want to ensure that they haven't made a mistake and what
they are inputting is indeed a valid account number. In this case it is possible to implement a function that takes the value of the AccountNum field and performs a database look up to
verify that the value does in fact exist. This check can run each time after the user has modified the AccountNum document field value and attempts to save their changes.
Example location: {Ephesoft_install_directory}\SharedFolders\BC1\scripts
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
2. Type “maven” and select “Maven project” from the list shown below.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
3. Check the “Create a simple project” option and click “Next”.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
4. Fill in the particulars for “Artifact” i.e. details about new project. These details include
1. “Group Id”: group id for the project as per maven artifacts standards
2. “Artifact Id”: artifact id, i.e. representation name for the plugin for use in various other projects.
3. “Version”: version of the plugin.
4. “Packaging”: type of packaging to be used for the project. In our application we use “jar” packaging.
After entering the above details for the new plugin, click on “Finish”.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
5. The structure shown below will be generated for the current project which includes the following:
1. “src” package: used for the storing the source code and resources used by the plugin.
2. “target” package: used for storing the target files i.e. the <b.“.class”</b> files, “.jar” files of the plugin.
3. “pom.xml” file: contains the information about the plugin.
Now start creating desired package structure for the project by right clicking on the “java” package and selecting the “new→others” option and selecting the
“package”.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
6. Type the hierarchical structure of the project and click on “Finish”.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
7. Above operation will create a package structure shown below.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
8. Create the desired files and corresponding folders for the plugin. Sample files can be found in the sample source code as well.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
9. Now that the plugin is ready with all the content, right click on the project name, go to “Run As” option and from the list shown choose “Maven Build”.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
10. A pop up window for editing the “Run/Debug” configuration will open up. In the “Goals” field, type “clean install”, check the “offline” and “Skip Tests” options and
then click “Apply”.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
11. For creating the jar file for the plugin following settings need to be taken care of:
1. Goto maven repository. Default path for the same is C:\Documents and Settings\{user-name}\.m2\repository folder.
2. Create the folder structure com\ephesoft\dcma\ephesoft\<VERSION_NUMBER> inside the repository folder.
3. Copy and paste the Ephesoft.jar inside the folder.
4. Rename Ephesoft.jar to Ephesoft-<Version_Number>.jar.
5. In the “pom.xml” file for the plugin make the following entry
<dependencies>
<dependency>
<groupId>com.ephesoft.dcma</groupId>
<artifactId>ephesoft</artifactId>
<version><VERSION_NUMBER></version>
</dependency>
</dependencies>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
6. Now that we have defined the dependencies for the plugin, we can use the existing code contained within the “ephesoft-<VERSION_NUMBER>.jar” for the desired
purpose.
12. Click on “Run”, this will run the maven project and make its “jar”. A .jar file corresponding to the plugin will be created in the target folder for the same.
5. BackUpFileService can be used to create backup xml files for the respective plugin.
Workflow Management
Introduction
• Establishments:
• A batch class is made of modules, which in turn consist of plugins.
• Dependencies between modules are only a result of the dependencies that exist between plugins.
Inference: By handling the dependencies that exist between plugins, we can create the Validation framework.
• Addition of a new tab in the admin view for workflow management by the name of “Workflow Management” containing the following:
• “Plugins List”: List of plugins already present.
• “Add New Plugin” button: For adding a new plugin.
• “Dependencies” button: On being clicked it will take user to a screen where it can manage the dependencies among the plugins.
• “Help” button: On being clicked the user will be shown a pop-up message containing the information about the new plugin upload.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
• “Add New plugin”: a plugin upload widget will open up. See the screenshot below
• “Browse”: a file selection window will open up.
• “Save”: this will save the plugin to the DB after validating the files.
• “Cancel”: this will cancel the operation.
• This widget will accept a .zip file for uploading.
• Contents of the zip file:
• .Jar file: The Jar for the plugin to be added.
• .Xml file: containing the plugin information.
• .Zip file must only contain these two files.
• .Zip file and .Jar file must have the same name.
• .Jar file content cannot be verified, so please make sure that they are as required.
• In order for this plugin to take effect, user needs to restart the tomcat server.
• Note:
• This Zip file after successful validation of its contents will be stored in the location specified in “<DCMA_HOME>\WEB-INF\classes\META-INF\application.properties” file
under the property named “plugin_upload_folder_path”.
• The JPDL file for the uploaded plugin will be stored at <Ephesoft-Shared-Folders\workflows\plugins\<PLUGIN_NAME> . This path is configurable in the dcma-
batch.properties file.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
XML Structure
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
<is-multivalue></is-multivalue>
<sample-values>
<sample-value></sample-value>
</sample-values>
</plugin-property>
</plugin-properties>
<dependencies>
<dependency>
<type-of-dependency></type-of-dependency>
<dependency-name></dependency-name>
</dependency>
</dependencies>
</plugin>
Assumptions
• “plugin-service-instance” and “method-name” tags must be correct as they cannot be validated. • “application-context-path” refers to the application context file name for the
plugin. • For the dependencies tag:
• For a new plugin, with dependencies as
o ORDER_BEFORE : P2,P3/P4,P5,P6/P7/P8
o UNIQUE : TRUE
o OR (/) operator and AND (,) operator are also supported for specifying complex dependencies.
<dependencies>
<dependency>
<type-of-dependency>ORDER_BEFORE </type-of-dependency>
<dependency-name>IMPORT_BATCH_FOLDER</dependency-name>
</dependency>
<dependency>
<type-of-dependency>ORDER_BEFORE </type-of-dependency>
<dependency-name>IMPORT_MULTIPAGE_FILES/CMIS_PLUGIN</dependency-name>
</dependency>
<dependency>
<type-of-dependency>ORDER_BEFORE </type-of-dependency>
<dependency-name>DOCUMENT_ASSEMBLER_PLUGIN,CLEAN_UP</dependency-name>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
</dependency>
</dependencies>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
There are shortcut keys as well as buttons defined to fire an External Application for a batch on the Review Validate UI. (App 1, App4, App2, App 3 as can be seen in the above UI)
When the shortcut key or the App button is pressed, the integrated application or module will be displayed in the Review Validation screen as Modal Window.
In the image below, the Right Hand side shows the image of the documents whereas the Left Hand side shows the integrated application/module.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
External Application
IMPORTANT: batch.xml must be updated by the external application. On the click of OK button, Ephesoft simply loads the updated batch.xml.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
shortcuts as you can see below:
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
As you can see in the screenshot of the External Application on the review-validate screen, there were two buttons present for closing the external application (earlier).
The OK button provided the functionality of refreshing and displaying refreshed content (on the review-validate screen) for the batch that has been modified through the external
application.
The CLOSE button simply goes back to the review-validate screen without refreshing the content of the batch, assuming that no changes have been made to the batch.xml by the
external application.
Now we have removed the extra click that the user has to do in case of refreshing the screen or closing the pop up dialog window.
Now both the functionalities (i.e. refreshing the screen after batch.xml updates or closing the pop up window without refreshing the Review Validate Screen) will be the implemented via
third party applications. We have provided a handle to the externally integrated applications by means of which they can communicate with the Ephesoft Application.
We have removed the ok and close buttons. External applications need to copy the below mentioned method in their code. They need to invoke this method on the respective button
(ok or close) calls which they have implemented. External applications will signal Ephesoft to perform respective operations by passing the appropriate operation string in the method
argument. Accepted operation strings are listed in the table below.
Method code for GWT based applications:
private native void fireEvent(String operation) /*-{
window.top.postMessage(operation,"*");
}-*/;
Method code for Javascript based applications:
function fireEvent(var operation) { window.top.postmessage(operation, “*”); }
The action performed by us in accordance to the argument passed to this method in the external application’s code:
The dialog box containing the external application on the review-validate screen closes, without refreshing the RV screen. (The functionality
"Cancel"
previously provided by the CLOSE button on the dialog box)
Any other string No Change (Dialog box will not disappear)
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
{Ext. App URL}&document_id={Document Identifier}&batch_xml_path={Path of batch.xml}&ticket={Security Token}
Or
{Ext. App URL}?document_id={Document Identifier}&batch_xml_path={Path of batch.xml}&ticket={Security Token}
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
if (null != batchLocalPathList) {
for (int index = 0; index < batchLocalPathList.getLength(); index++) {
Node batchLocalPathNode = batchLocalPathList.item(index);
batchLocalPath = batchLocalPathNode.getTextContent();
}
}
if (null == batchLocalPath) {
System.err.println("Unable to find the local folder path in batch xml file.");
return;
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
String batchInstanceID = null;
NodeList batchInstanceIDList = document.getElementsByTagName(BATCH_INSTANCE_ID);
if (null != batchInstanceIDList) {
for (int index = 0; index < batchInstanceIDList.getLength(); index++) {
Node batchInstanceIDNode = batchInstanceIDList.item(index);
batchInstanceID = batchInstanceIDNode.getTextContent();
}
}
if (null == batchInstanceID) {
System.err.println("Unable to find the batch instance ID in batch xml file.");
return;
}
String batchXMLPath = batchLocalPath.trim() + File.separator + batchInstanceID + File.separator + batchInstanceID
+ EXT_BATCH_XML_FILE;
String batchXMLZipPath = batchXMLPath + ZIP_FILE_EXT;
System.out.println("batchXMLZipPath************" + batchXMLZipPath);
Source source = new DOMSource(document);
File zipFile = new File(batchXMLZipPath);
OutputStream outputStream = null;
try {
if (zipFile.exists()) {
System.out.println("Found the batch xml zip file.");
outputStream = getOutputStreamFromZip(batchXMLPath, batchInstanceID + EXT_BATCH_XML_FILE);
} else {
System.out.println("Found the batch xml file.");
outputStream = new FileOutputStream(new File(batchXMLPath));
}
Result result = new StreamResult(outputStream);
Add the following method to the script java class file, as it is required by the new writeToXml() function:
public static OutputStream getOutputStreamFromZip(final String zipName, final String fileName) throws FileNotFoundException, IOException {
ZipOutputStream stream = null;
stream = new ZipOutputStream(new FileOutputStream(new File(zipName + ZIP_FILE_EXT)));
ZipEntry zipEntry = new ZipEntry(fileName);
stream.putNextEntry(zipEntry);
return stream;
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Sample Scripts for comparison DOM and JDOM: Let’s take the simple example for converting dom scripts into JDOM scripts.
1) Change the import statement
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
to
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
2) Change the implements statement :
IJDomScript is the interface for running the JDOM Scripts. Each scripts should implements IJDomScript for running the customize script using JDOM.
public class ScriptAutomaticValidation implements IScripts {
to
public class ScriptAutomaticValidation implements IJDomScript {
3) API difference in JDOM w.r.t DOM
Getting the list document object in JDOM is different from DOM: In JDOM we need to iterate each node for getting the child element list because JDOM doesn’t access the
child tag directly without accessing the parent tag of that child tag.
Getting Pages Nodes in JDOM vs. DOM
JDOM Case:
// Getting PAGES tag with accessing its parent in batch.xml
// Getting first child of root node
Element documents = document.getRootElement().getChild(DOCUMENTS);
// Getting first child of DOCUMENTS node
List documentList = documents.getChildren(DOCUMENT);
for (int documentIndex = 0; documentIndex < documentList.size(); documentIndex++) {
Element document = (Element) documentList.get(documentIndex);
Element pages = (Element) document.getChild(PAGES);
}
DOM Case:
// Getting directly PAGES tag without accessing its parent in batch.xml
NodeList documentList = document.getElementsByTagName(PAGES);
Getting Text Content from element:
JDOM Case:
String elementValue = element.getText();
DOM Case:
String elementValue = element.getTextContent();
Setting Text Context in element:
JDOM Case:
element.setText(“String Data”);
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
DOM Case:
element.setTextContent(“String Data”);
4) Used the following code for writing the XML using JDOM Scripts inside the Custom Script:
Call the following code for saving the XML e.g. writeToXML(document);
This code use the following method for saving the document.
/**
* The writeToXML method will write the state document to the XML file.
*
* @param document {@link Document}.
*/
private void writeToXML(Document document) {
String batchLocalPath = null;
List<?> batchLocalPathList = document.getRootElement().getChildren(BATCH_LOCAL_PATH);
if (null != batchLocalPathList) {
batchLocalPath = ((Element) batchLocalPathList.get(0)).getText();
}
if (null == batchLocalPath) {
System.err.println("Unable to find the local folder path in batch xml file.");
return;
}
String batchInstanceID = null;
List<?> batchInstanceIDList = document.getRootElement().getChildren(BATCH_INSTANCE_ID);
if (null != batchInstanceIDList) {
batchInstanceID = ((Element) batchInstanceIDList.get(0)).getText();
}
if (null == batchInstanceID) {
System.err.println("Unable to find the batch instance ID in batch xml file.");
return;
}
String batchXMLPath = batchLocalPath.trim() + File.separator + batchInstanceID + File.separator + batchInstanceID
+ EXT_BATCH_XML_FILE;
String batchXMLZipPath = batchXMLPath + ZIP_FILE_EXT;
System.out.println("batchXMLZipPath************" + batchXMLZipPath);
OutputStream outputStream = null;
File zipFile = new File(batchXMLZipPath);
FileWriter writer = null;
XMLOutputter out = new XMLOutputter();
try {
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
if (zipFile.exists()) {
System.out.println("Found the batch xml zip file.");
outputStream = getOutputStreamFromZip(batchXMLPath, batchInstanceID + EXT_BATCH_XML_FILE);
out.output(document, outputStream);
} else {
writer = new java.io.FileWriter(batchXMLPath);
out.output(document, writer);
writer.flush();
writer.close();
}
} catch (Exception e) {
System.err.println(e.getMessage());
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
}
}
}
}
For more reference please see the http://www.jdom.org/docs/faq.html
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Create a new Java Application Project:
To implement and build the Ephesoft scripting classes the Ephesoft.jar file must be added under the project dependencies.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Browse to the location of your Ephesoft installation’s library folder and locate Ephesoft.jar. The default path on the server machine is: C:\Ephesoft\Application\WEB-INF\lib
As a point of reference for Ephesoft script development you can examine the script files that are packaged with the default batch classes Ephesoft ships with.
C:\Ephesoft\SharedFolders\BC1\scripts
This screenshot depicts and implementation of the ScriptExtraction.java class file. However in this case a main() method has been added to allow for testing & debugging by
execution within the class.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
At this stage the main() method has been implemented to allow for the reading in of an Ephesoft batch .xml file, and passing that Document object to the ScriptExtraction execute()
method.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
{
try {
SAXBuilder sb = new SAXBuilder();
Document doc = sb.build("BI10A_batch.xml");
ScriptExtraction extractor = new ScriptExtraction();
extractor.execute(doc, null, null);
} catch(Exception e) {
e.printStackTrace();
}
}
With the main() method in place it is now possible to execute the ScriptExtraction class. Successful execution is confirmed by the print statements in the NetBeans output section.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Web Services API
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Here is the code for making authenticated client calls via Ephesoft Web Services:-
Credentials defaultcreds = new UsernamePasswordCredentials("username", "password"); client.getState().setCredentials(new AuthScope("serverName", 8080), defaultcreds);
client.getParams().setAuthenticationPreemptive(true);
createSearchablePDF
This API will generate the searchable pdf. It takes the input tif/tiff files and rsp file for processing. Input parameters will used to specify the output pdf is searchable or color.
Web Service url: http://{serverName}:{port}/dcma/rest/createSearchablePDF
Checklist:
i. Input only tiff, tif files for generating searchable pdf.
ii. RSP file is mandatory for generating the searchable pdf.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
fileOutputStream.close();
}
}
System.out.println("Web service executed successfully.");
} else if (statusCode == 403) {
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing.");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
convertTiffToPdf
This API will generates the pdf for the input tiffs. If 5 input tiffs are provided then 5 pdf will return using this api. This API will have following parameter for configuration.
Web Service URL : http://{serverName}:{port}/dcma/rest/convertTiffToPdf
Checklist:
i. Input only tiff, tif files for generating pdf.
ii. If pdfGeneratorEngine is “IMAGE_MAGICK”, than only input params and output params are works.
iii. If Input tiff is multipage tiff than single multipage pdf is generated as output.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
convert-tiff-to-pdf.zip
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
fos.close();
}
}
} else if (statusCode == 403) {
System.out.println("Invalid username/password..");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing.");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
splitMultipageFile
This API will break the pdf and multipage tiff into single page tiff. This will used the image magick and ghost script for splitting the input file. This API will have following parameter for
configuration.
Web Service URL : http://{serverName}:{port}/dcma/rest/splitMultipageFile
Input
Values Descriptions
Parameter
For Image MagicK:
This value can be empty. Reference for image magick parameter. http://www.imagemagick.org/script/command-line- This parameter will used for both image magick
inputParams
options.php For Ghost Script: This value should not be empty. Reference for ghost script input parameter : and ghost script.
http://ghostscript.com/doc/8.54/Use.htm#Output_device
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Checklist
i. Input only tiff and pdf file only.
ii. If “isGhostscript” is “true”, than only input params will works and file only break PDF files.
iii. If “isGhostscript” is “false”, than input params and output params will works.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
}
System.out.println("Web service executed successfully..");
} else if (statusCode == 403) {
System.out.println("Invalid username/password..");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing..");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
createMultipageFile
This API will create the multipage tif/pdf using “Image MagicK”, “IText” and “GhostScript”. This API works only for tif/tiff files and provided XML file for input parameters. This API will
have following parameter for configuration
Web Service URL : http://{serverName}:{port}/dcma/rest/createMultiPageFile
multipageTifSwitch Either “ON”/”OFF” This parameter is used for generating multipage tif along with multipage pdf.
pdfOptimizationSwitch Either “ON”/”OFF” This switch is used for generated optimized pdf.
This value should not be empty. Reference for ghost script input
ghostscriptPdfParameters parameter : This are the ghost script parameter used for creating multipage pdf.
http://ghostscript.com/doc/8.54/Use.htm#Output_device
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Checklist
i. Input only tiff file for processing and xml file for inputs.
ii. If “imageProcessingAPI” is “GHOSTSCRIPT”, than only ghostscriptPdfParameters will works.
iii. If “pdfOptimizationSwitch” is “ON”, than pdfOptimizationParams will works.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
String url = "http://localhost:8080/dcma/rest/createMultiPageFile ";
PostMethod mPost = new PostMethod(url);
// Adding XML file for parameters
File file1 = new File("C:\\sample\\WebServiceParams.xml");
// Adding tif file for processing
File file2 = new File("C:\\sample\\sample1.tif");
File file3 = new File("C:\\sample\\sample2.tif");
Part[] parts = new Part[3];
try {
parts[0] = new FilePart(file1.getName(), file1);
parts[1] = new FilePart(file2.getName(), file2);
parts[2] = new FilePart(file3.getName(), file3);
MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
mPost.setRequestEntity(entity);
int statusCode = client.executeMethod(mPost);
if (statusCode == 200) {
InputStream inputStream = mPost.getResponseBodyAsStream();
// Retrieving file from result
File file = new File("C:\\sample\\serverOutput.zip");
FileOutputStream fos = new FileOutputStream(file);
try {
byte[] buf = new byte[1024];
int len = inputStream.read(buf);
while (len > 0) {
fos.write(buf, 0, len);
len = inputStream.read(buf);
}
} finally {
if (fos != null) {
fos.close();
}
}
System.out.println("Web service executed successfully..");
} else if (statusCode == 403) {
System.out.println("Invalid username/password..");
} else {
System.out.println(statusCode + " *** " + mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing..");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
classifyImage
This API classify the input image as per batch class identifier provided. This API will depend on the three plugin for completion “CREATE_THUMBNAILS_PLUGIN”,
“CLASSIFY_IMAGES_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”. If any batch class doesn’t have those plugin than classify image api will not work.
Web Service URL : http://{serverName}:{port}/dcma/rest/classifyImage
Input
Values Descriptions
Parameter
This value should not be empty and it should be batch class identifier as This parameter is used for providing batch class identifier on which classify image will
batchClassId
like BC1. perform..
Checklist:
i. Input file should be single page tif/tiff file only.
ii. batchClassId should be valid batch class identifier and must have the “CREATE_THUMBNAILS_PLUGIN”, “CLASSIFY_IMAGES_PLUGIN” and
“DOCUMENT_ASSEMBLER_PLUGIN”.
classifyBarcodeImage
This API is used to classify the input image as per specified batch class. Image file should have barcode and barcode value should be document type which is present in the batch
class.
Web Service URL: http://{serverName}:{port}/dcma/rest/classifyBarcodeImage
Input
Values Descriptions
Parameter
This value should not be empty and it should be batch class identifier as This parameter is used for providing batch class identifier on which classify HOCR will
batchClassId
like BC1 perform.
Checklist:
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
i. Input file should be tif/tiff file only.
ii. batchClassId should be valid batch class identifier and must have the “BARCODE_READER_PLUGIN” .
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
classifyHOCR
This API will classify the input HOCR as per batch class identifier provided. This API will depend on the following plugins “SEARCH_CLASSIFICATION_PLUGIN”,
“DOCUMENT_ASSEMBLER_PLUGIN” and the learning done on the batch class. If any batch class doesn’t have those plugins than classify hocr will not work.
Web Service URL : http://{serverName}:{port}/dcma/rest/classifyHOCR
Input
Values Descriptions
Parameter
This value should not be empty and it should be batch class identifier as This parameter is used for providing batch class identifier on which classify HOCR will
batchClassId
like BC1. perform.
Checklist
i. Input file should be html file only.
ii. batchClassId should be valid batch class identifier and must have the “SEARCH_CLASSIFICATION_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
try {
parts[0] = new FilePart(hocrXmlFile.getName(), hocrXmlFile);
// Adding parameter for batchClassId
parts[1] = new StringPart(BATCH_CLASS_ID_PARAM, batchClassId);
MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
mPost.setRequestEntity(entity);
int responseCode = client.executeMethod(mPost);
if (responseCode == 200) {
System.out.println("Web service executed successfully..");
String responseBody = mPost.getResponseBodyAsString();
System.out.println(responseCode + " *** " + responseBody);
} else if (responseCode == 403) {
System.out.println("Invalid username/password..");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing..");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
classifyMultiPageHOCR
This API will classify the input HOCR as per batch class identifier provided. This API will depend on the following plugins “SEARCH_CLASSIFICATION_PLUGIN”,
“DOCUMENT_ASSEMBLER_PLUGIN” and the learning done on the batch class. Both the mentioned plugins should be present and also should be ON. If any batch class doesn’t have
those plugins then classify hocr will not work.
Input
Values Descriptions
Parameter
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
This value should not be empty and it should be batch class identifier as This parameter is used for providing batch class identifier on which classify HOCR will
batchClassId
like BC1. perform.
Checklist:
i. Input file should be zip file containing HOCR.xml’s in it.
ii. batchClassId should be valid batch class identifier and must have the “SEARCH_CLASSIFICATION_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN”.
extractKV
This API will extract the document level fields for the corresponding Key Value pattern provided using input XML. This API will take the HOCR xml file as a input. If the Key Value
pattern not found in the HOCR file then it will create empty document level fields. Web Service URL : http://{serverName}:{port}/dcma/rest/extractKV
Batch Class List >>Recostar Mail Room [BC1] >>Application-Checklist >>Invoice Date >>New KV Extraction
Input
Values Descriptions
Parameter
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
AdvancedKV Either “true”/”false” This parameter is used to specifying the KeyValue extraction is perform by advanced key value or not.
This value should be one of the following:
LocationType TOP, RIGHT, LEFT, BOTTOM, TOP_RIGHT, This parameter will fetch the Value pattern of the particular key pattern on the location provided
TOP_LEFT, BOTTOM_LEFT, BOTTOM_RIGHT
This parameter is used for specify in case of AdvancedKV is false. This parameter is used for adding number
NoOfWords Should be Integer
word of RIGHT location in the result of the value pattern found in the HOCR file.
This value should not be empty.
KeyPattern This is used to verify the Key pattern present in given HOCR
This value should be valid regex expression.
This value should be float and should be in between 0 This value is used to multiply with confidence for updating the confidence of the fields extracted using
Multiplier
to 1 advanced KV.
Length This value should be integer For getting length value use Ephesoft Admin Screen as display screen shot above
Width This value should be integer For getting width value use Ephesoft Admin Screen as display screen shot above
Xoffset This value should be integer For getting xoffset value use Ephesoft Admin Screen as display screen shot above
Yoffset This value should be integer For getting yoffset value use Ephesoft Admin Screen as display screen shot above
CheckList:
i. For using Advance KV user should have admin access to fetch the accurate value of Length, Width, Xoffset and Yoffset. Before using AdvancedKV, please test the image
with Ephesoft Admin Screen and note the values of Length, Width, Xoffset, Yoffset and LocationType for the particular KeyValue pattern.
ii. If AdvancedKV is true than NoOfWords is not use and all other parameters is used.
iii. If AdvancedKV is false than NoOfWords, KeyPattern, ValuePattern and LocationType will work.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
System.out.println("Web service executed successfully.");
String responseBody = mPost.getResponseBodyAsString();
// Generating result as responseBody.
System.out.println(responseCode + " *** " + responseBody);
} else if (responseCode == 403) {
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing.");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
extractFixedForm
This API extracts the document level fields from the given RSP file and the image provided. This image should be tif/png
Web Service URL : http://{serverName}:{port}/dcma/rest/extractFixedForm
Input
Values Descriptions
Parameter
This parameter is used for extracting the data from color image or black and white
colorSwitch Either “ON”/”OFF”
image.
This value should not be empty and should have valid recostar project file
projectFile This is used for HOCRing the image file using project file associated.
name.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
<_Library Type="Dll" BaseName="Recognition"/>
</_Collection>
<FormOperator Name="Operator" SetupImageFileName="" ProjectID="0" DefaultFormType="Voting_Pharmacy" ExternalFormType="" Country="USA" FormRegistration="Off"
FormReading="true" FormGeometry="0 0 0 0 0 0" ResultCoordinates="OriginalImage" ResultImage="Off" ResultGraphicalObjects="false" PassThroughID="Ignore"
DiagnosticsMode="OnError" DiagnosticsFileName="">
<ImageSequence2Operator Name="ImageProcessing" SetupImageFileName="" RegisterImage="false" DiagnosticsMode="OnError" DiagnosticsFileName=""
ConfigurationFileName="" Geometry="0 0 1488 0 0 1019">
<LoadImageOperator Name="ImageSourceOperator" FileName="" FileFormat="Unknown" Resolution="ReadFromFile" UnifyResolution="false" RepairResolution="false"
AutoRotate="false" IgnorePalette="true" ScaleToGray="0"/>
<ExtractGrayFromRgbOperator Name="ColorFilterOperator" LumaRed="0.299" LumaGreen="0.587" LumaBlue="0.114"/>
<BinarizeEdgeAdaptiveOperator Name="BinarizeOperator" EdgeThreshold="80" DoubleResolution="false"/>
<_Collection Name="BinaryImageSequence">
<DetectPaperAreaOperator Name="DetectPaperArea" KeepBlackFrame="false" SafetyClass="Medium" DetectTextSkew="false"/>
</_Collection>
</ImageSequence2Operator>
<_Collection Name="Forms">
<FormRecoOperator Name="Voting_Pharmacy" SetupImageFileName="" SetupImageWidth="125.98" SetupImageHeight="86.27">
<_Collection Name="RecoOperators">
<IcrField Name="Field1" Zone="440 1151 11269 796 0 1" ReaderSelection="Voter" Orientation="Normal" SyntaxMode="Alphanumerical" Font="Unknown" NumberOfLines="1"
HandprintHeight="5.50" HandprintPitch="5.00" HandprintMinConfidence="100" MachinetypeHeight="Unknown" MachinetypePitch="Unknown"
MachinetypeMinConfidence="100" LogicalContext="On" TrigramMode="On" DictionaryFileName="" DictionaryMode="Incomplete" DictionaryCandidates="Words"
CharacterSet="" Pattern="^[$%*+,\-.0-9:;<=>?A-Z\\a-z]*$" LeftBoundaryHandling="On" TopBoundaryHandling="On" RightBoundaryHandling="On"
BottomBoundaryHandling="On" Classifiers="" PassThroughID="None">
<_Collection Name="IgnoreAreas"/>
</IcrField>
<IcrField Name="Field2" Zone="593 1930 11803 796 0 1" ReaderSelection="Voter" Orientation="Normal" SyntaxMode="Numerical" Font="Unknown" NumberOfLines="1"
HandprintHeight="5.50" HandprintPitch="5.00" HandprintMinConfidence="100" MachinetypeHeight="Unknown" MachinetypePitch="Unknown"
MachinetypeMinConfidence="100" LogicalContext="On" TrigramMode="On" DictionaryFileName="" DictionaryMode="Incomplete" DictionaryCandidates="Words"
CharacterSet="" Pattern="^[$*+,\-.0-9\\]*$" LeftBoundaryHandling="On" TopBoundaryHandling="On" RightBoundaryHandling="On" BottomBoundaryHandling="On"
Classifiers="" PassThroughID="None">
<_Collection Name="IgnoreAreas"/>
</IcrField>
</_Collection>
</FormRecoOperator>
</_Collection>
<FormGenerator Name="Generator"/>
</FormOperator>
</_Project>
CheckList:
i. projectFile should have fields like we have marked yellow in above.
ii. If colorSwitch is ON than image should be png.
iii. If colorSwitch is OFF than image should be tif/tiff.
extractFieldFromHocr
This API will extract the KV pattern for the given word in the given HOCR file. Web Service URL : http://{serverName}:{port}/dcma/rest/extractFieldFromHocr
CheckList:
i. fieldValue is provided for the word on which Key Value pattern would be found.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
extractFuzzyDB
This API will create the document level fields for the document type for the specified batch class for HOCR file passing it.
Web Service URL : http://{serverName}:{port}/dcma/rest/extractFuzzyDB
CheckList:-
i. hocrFile should have same HOCR file name that are passed for processing.
ii. BatchClass having that batchClassIdentifier should have fuzzyDB plugin for processing.
iii. DocumentType should have document level fields for specified document type.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
if (statusCode == 200) {
System.out.println("Web service executed successfully.");
String responseBody = mPost.getResponseBodyAsString();
// Generating result as responseBody.
System.out.println(statusCode + " *** " + responseBody);
} else if (statusCode == 403) {
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing.");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
barcodeExtraction
This API will create the document level fields for the document type for the specified batch class for barcode in tiff files passing it.
Web Service URL : http://{serverName}:{port}/dcma/rest/barcodeExtraction
CheckList:-
i. BatchClass having that batchClassIdentifier should have Barcode Extraction plugin for processing.
ii. DocumentType should have document level fields for specified document type.
iii. Image name should have valid extension i.e. TIF/TIFF.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Sample Input Used:
barcodeExtraction.zip
regularRegexExtraction
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
This API will extract the document level fields for the document type for the specified batch class.
Web Service URL : http://{serverName}:{port}/dcma/rest/extractFieldsUsingRegex
CheckList:-
i. This batch class specified should have Regular Regex plugin defined for it.
ii. DocumentType should have document level fields for specified document type.
iii. HOCR file name should have valid extension, i.e., HTML.
commonAPIForExtraction
This API is required to set the Header in the client for which the extraction to be performed. Rest of the information for the individual api found above.
Input for Extraction Type:
Pass the name of extraction api that is to use in the client header as shown in following example: BARCODE_EXTARCTION, RECOSTAR_EXTARCTION,
REGULAR_REGEX_EXTRACTION, KV_EXTRACTION, FUZZY_DB
Here’s the sample client code using Regular Regex Extraction:
private static void extractFields() {
HttpClient client = new HttpClient();
String url = "http://localhost:8080/dcma/rest/extractFields ";
PostMethod mPost = new PostMethod(url);
File file1 = new File("C:\\sample\\input\\sample1.html");
// adding xml file for taking input
File file2 = new File("C:\\sample\\input\\WebServiceParams.xml");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Part[] parts = new Part[2];
try {
parts[0] = new FilePart(file1.getName(), file1);
parts[1] = new FilePart(file2.getName(), file2);
MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
/* Pass the name of extraction api that is to used:
BARCODE_EXTARCTION
RECOSTAR_EXTARCTION
REGULAR_REGEX_EXTRACTION
KV_EXTRACTION
FUZZY_DB*/
Header header = new Header("extractionAPI", "REGULAR_REGEX_EXTRACTION");
mPost.addRequestHeader(header);
mPost.setRequestEntity(entity);
if (statusCode == 200) {
System.out.println("Web service executed successfully.");
System.out.println(mPost.getResponseBodyAsString());
} else if (statusCode == 403) {
System.out.println("Invalid username/password.");
} else {
::::System.out.println(mPost.getResponseBodyAsString());
} } catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
createOCR
This API will generates the OCR result for the specified sample image file. This API works for tif and png file. If processing the color image we accept the png/tif file as input and for
black and white image we processing tif file as input.
Web Service URL : http://{serverName}:{port}/dcma/rest/createOCR
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Input Parameter Values Descriptions
ocrEngine Either “recostar”/”tesseract” This parameter is used for configuring the ocrEngine to be used
colorSwitch Either “ON”/”OFF” This parameter is used
tesseractVersion Currently we are supporting “tesseract_version_3” This parameter is used for tesseract version to be used.
cmdLanguage Either “tha”/”eng” This parameter is used for configure the language that has been learnt by tessearact
projectFile This can be empty in case of tesseract ocrEngine This parameter is validating the RSP used for OCRing in case of recostar
CheckList:-
i. In case of ocrEngine is recostar, than colorSwitch and projectFile is mandatory parameters.
ii. In case of ocrEngine is tesseract than colorSwitch, tesseractVersion and cmdLanguage is mandatory parameters.
iii. If colorSwitch is ON, input image can be tif/png.
iv. If colorSwitch is OFF than input image should be TIFF.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
</Param>
</Params>
</WebServiceParams>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
// adding image file for processing
File file1 = new File("C:\\sample\\sample1.tif");
// adding xml file for taking input
File file2 = new File("C:\\sample\\WebServiceParams.xml");
// adding rsp file used for creating OCR in case of recostar
File file3 = new File("C:\\sample\\Fpr.rsp");
Part[] parts = new Part[3];
try {
parts[0] = new FilePart(file1.getName(), file1);
parts[1] = new FilePart(file2.getName(), file2);
parts[2] = new FilePart(file3.getName(), file3);
MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
mPost.setRequestEntity(entity);
int statusCode = client.executeMethod(mPost);
if (statusCode == 200) {
System.out.println("Web service executed successfully.");
InputStream in = mPost.getResponseBodyAsStream();
// saving result generated.
File outputFile = new File("C:\\sample\\serverOutput.zip");
FileOutputStream fos = new FileOutputStream(outputFile);
try {
byte[] buf = new byte[1024];
int len = in.read(buf);
while (len > 0) {
fos.write(buf, 0, len);
len = in.read(buf);
}
} finally {
if (fos != null) {
fos.close();
}
}
} else if (statusCode == 403) {
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing.");
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
getBatchInstanceForRole
This API is used to fetch all batch instance list having accessed by the specified role. This API is GET api, works with web url and client code.
Web Service URL : http://{serverName}:{port}/dcma/rest/getBatchInstanceForRole/{role}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (getMethod != null) {
getMethod.releaseConnection();
}
}
}
getBatchClassForRole:
This API is used to fetch all batch class list having accessed by the specified role. This API is GET api, works with web url and client code.
Web Service URL : http://{serverName}:{port}/dcma/rest/getBatchClassForRole/{role}
runReporting
This API is used to run reporting on using web services. This web service takes server side installer path as an input and performs synchronizing the report database.
Web Service URL : http://{serverName}:{port}/dcma/rest/runReporting
Checklist :-
i. This path should be valid file path and must be server path for the build.xml file.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
parts[0] = new FilePart(file1.getName(), file1);
MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
mPost.setRequestEntity(entity);
int statusCode = client.executeMethod(mPost);
if (statusCode == 200) {
System.out.println("Web service executed successfully.");
String responseBody = mPost.getResponseBodyAsString();
System.out.println(statusCode + " *** " + responseBody);
} else if (statusCode == 403) {
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.out.println("File not found for processing.");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
getBatchInstanceList
This api will return the batch instance list of the batch instance status accessed for the specific role using in the authentication. This API is GET api, works with client code and URL
directly.
Web Service URL : http://{serverName}:{port}/dcma/rest/getBatchInstanceList/{status}
Input
Values Descriptions
Parameter
This values can be NEW, LOCKED,READY,ERROR, FINISHED,ASSIGNED, RUNNING, READY_FOR_REVIEW,
status READY_FOR_VALIDATION, RESTARTED, DELETED, TRANSFERRED, RESTART_IN_PROGRESS || This parameter is used for specifying the batch
instance status for which batch instance list to be fetched.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Checklist:-
i. Status should have status provided above in the list.
getAllModulesWorkflowNameByBatchClass
API will returns the module workflow names and the module names of the specified batch class identifier. This API is GET API, works with client code and web url.
Web Service URL : http://{serverName}:{port}/dcma/rest/getAllModulesWorkflowNameByBatchClass/{batchClassIdentifier}
restartBatchInstance
This API is used to restart the batch instance from specified module. User can restart those batch instances those are accessible by their role. This API is GET api, works with client
code and web url.
Web Service URL : http://{serverName}:{port}/dcma/rest/restartBatchInstance/{batchInstanceIdentifier}/{restartAtModuleName}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
batchClassIdentifier This value should be valid batch instance identifier. This parameter is used to specifying the batch instance identifier for which batch instance to be restart.
restartAtModuleName This value should not be empty This parameter is used specifying the module name from where batch to be restart.
Checklist:-
i. Batch Instance identifier should be valid identifier and having access by the user which are authenticate the web service.
ii. restartAtModuleName this value should valid module name and it can be differ with batch class.
deleteBatchInstance
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
This API is used to delete the batch instance for specified batch instance identifier. This API will delete that batch instance having accessed by the authenticated user.
Web Service URL : http://{serverName}:{port}/dcma/rest/deleteBatchInstance/{identifier}
restartAllBatchInstance
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
This API is used to restart all the batch instance having status READY_FOR_REVIEW and READY_FOR_VALIDATION and having access by the authenticated user. This API is GET
API, works with clinet code and web url.
Web Service URL : http://{serverName}:{port}/dcma/rest/restartAllBatchInstance
Checklist:-
i. Only those batch will restart having status READY_FOR_REVIEW and READY_FOR_VALIDATION which are accessible by authenticated user.
addUserRolesToBatchInstance
This API is used to adding roles to batch instance identifier. This API takes batch instance identifier and role name as an input and adding it to the database. This API is GET api,
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
works with client code and web browser both.
Web Service URL : http://{serverName}:{port}/dcma/rest/addUserRolesToBatchInstance/{batchInstanceIdentifier}/{userRole}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
importBatchClass
This API is used for importing batch class to the ephesoft. This API takes XML for input parameters and exported batch class data as an input. Exported batch class is in zip format as
exported by Ephesoft.
Web Service URL : http://{serverName}:{port}/dcma/rest/importBatchClass
Input
Values Descriptions
Parameter
RolesImported Either “true”/”false” This value is used for importing roles with batch class or not.
EmailAccounts Either “true”/”false” This value is used for importing email accounts with batch class or not.
UseSource Either “true”/”false” This value is used for saving the information of source batch class to be imported
Name This value should not be empty This value is used to configure the batch class name of the imported batch class.
Description This value should not be empty This value is used to configure the description of the imported batch class.
Priority This value should lie in between 1 to 100. This value indicates the priority of batch class.
UseExisting Either “true”/”false” This value is used for overwrite the existing batch class with new batch class.
This value should not be empty and have any string value that specified These values specify the UNC folder path for batch class to be imported along with
UncFolder
directory path batch class.
Script This tag is configured for ScriptFile to be imported This tag is configured for which Script file to be imported
Folder This tag is configured for Folder to be imported This tag is configured for which folder to be imported along with batch class
Checklist:-
i. If UseExisting is “true”, existing batch class will be overwriting with the Folders and Script as well as others parameter.
ii. If UseExisting is “false”, new batch class will created and Folders and Scripts will be used as false.
iii. If UseSource is “true”, new batch class will have same Name, Description and Priority as source batch class.
iv. If UseSource is “false”, new batch class will have property like Name, Description and Priority configured.
SampleInputXML:
<ImportBatchClassOptions>
<RolesImported>false</RolesImported>
<EmailAccounts>true</EmailAccounts>
<UseSource>false</UseSource>
<Name>BatchClassName</Name>
<Description>Description</Description>
<Priority>10</Priority>
<UseExisting>true</UseExisting>
<UncFolder>C:\ephesoft-data\Test-UNC</UncFolder>
<BatchClassDefinition>
<Scripts>
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
<Script>
<FileName>ScriptDocumentAssembler.java</FileName>
<Selected>true</Selected>
</Script>
<Script>
<FileName>ScriptPageProcessing.java</FileName>
<Selected>true</Selected>
</Script>
</Scripts>
<Folders>
<Folder>
<FileName>image-classification-sample</FileName>
<Selected>false</Selected>
</Folder>
</Folders>
<BatchClassModules>
<BatchClassModule>
<ModuleName></ModuleName>
<PluginConfiguration>true</PluginConfiguration>
</BatchClassModule>
</BatchClassModules>
</BatchClassDefinition>
</ImportBatchClassOptions>
Sample client code using apache commons http client:-
private static void importBatchClass() {
HttpClient client = new HttpClient();
String url = "http://localhost:8080/dcma/rest/importBatchClass ";
PostMethod mPost = new PostMethod(url);
mPost.setDoAuthentication(true);
// Input XML for adding parameter.
File file1 = new File("C:\\sample\\importbatchclass.xml");
// Input zip file for importing batch class.
File file2 = new File("C:\\sample\\BC1_050712_1714.zip");
Part[] parts = new Part[2];
try {
parts[0] = new FilePart(file1.getName(), file1);
parts[1] = new FilePart(file2.getName(), file2);
MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams());
mPost.setRequestEntity(entity);
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
int statusCode = client.executeMethod(mPost);
if (statusCode == 200) {
System.out.println("Batch class imported successfully");
} else if (statusCode == 403) {
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.out.println("File not found for processing.");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
exportBatchClass
This API is used for exporting existing batch class. This method will take the batch class identifier and learnt-sample to be exported with the batch class.
Web Service URL : http://{serverName}:{port}/dcma/rest/exportBatchClass
CheckList:-
i. Identifier should be batch class identifier.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
private static void exportBatchClass() {
HttpClient client = new HttpClient();
String url = "http://localhost:8080/dcma/rest/exportBatchClass ";
PostMethod mPost = new PostMethod(url);
mPost.addParameter("identifier", "BC1");
mPost.addParameter("lucene-search-classification-sample", "true");
mPost.addParameter("image-classification-sample", "false");
int statusCode;
try {
statusCode = client.executeMethod(mPost);
if (statusCode == 200) {
System.out.println("Batch class exported successfully");
InputStream in = mPost.getResponseBodyAsStream();
File f = new File("C:\\sample\\serverOutput.zip");
FileOutputStream fos = new FileOutputStream(f);
try {
byte[] buf = new byte[1024];
int len = in.read(buf);
while (len > 0) {
fos.write(buf, 0, len);
len = in.read(buf);
}
} finally {
if (fos != null) {
fos.close();
}
}
} else if (statusCode == 403) {
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}
}
}
getBatchClassList
This API returns all the batch class having accessible by the authenticated user. This API is GET API, works with the client code and web url.
Web Service URL : http://{serverName}:{port}/dcma/rest/getBatchClassList
getRoles
This API is used to get the roles of the specified batch class. This API is GET API, works with the client code and web url.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Web Service URL : http://{serverName}:{port}/dcma/rest/getRoles/{batchClassIdentifier}
CheckList:-
i. Identifier should be batch class identifier.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
This API is for uploading a new batch to a watch folder for a given batch class. It executes the new batch with supplied tif, tiff or pdf files. User need to be authorized to execute a batch
for a particular batch class otherwise an error message would be generated. All the files would be copied to the unc folder of the requested batch class with the folder name supplied by
the user as input.
CheckList:
i. The value for batchClassIdentifier is compulsory and should be valid with permissions to the user to run the batch on it.
ii. The value for batchInstanceName is compulsory and if left empty then it will send an error.
mPost.setRequestEntity(entity);
int statusCode = client.executeMethod(mPost);
String responseBody = mPost.getResponseBodyAsString();
// Generating result as responseBody.
System.out.println(statusCode + "***" + responseBody);
if (statusCode == 200) {
System.out.println("Web service executed successfully.");
} else if (statusCode == 403) {
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
System.out.println("Invalid username/password.");
} else {
System.out.println(mPost.getResponseBodyAsString());
}
} catch (FileNotFoundException e) {
System.err.println("File not found for processing.");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (mPost != null) {
mPost.releaseConnection();
}
}
}
This page w as last modified on 12 April 2013, at 13:12. This page has been accessed 41,006 times. Privacy policy About Ephesoft Community Disclaimers
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com