- Introducing ABBYY FlexiCapture
- ABBYY FlexiCapture architecture
-
Using scripts in ABBYY FlexiCapture
- Specifics of scripts written in .Net languages
- External assemblies
- Script editor
- Object model
-
Scripts for customizing processing stages
-
Types of scripts
- Script rule
- Autocorrection script
- Export script
- User script (custom action)
- Document assembly script
- Custom recognition script
- Stage rule
- Processing scripts
- Data set update script
- Data set validation scripts
- Document classification script
-
Event handlers
- Batch created
- Batch deleted
- Batch parameter change
- Batch structure change (page added/page deleted/document added/document deleted)
- Pages moved
- Batch opened/closed
- Batch integrity check
- Document parameter changed
- Document state changed
- Export completed
- Script that is run after rule checks
- Before matching
- Field verification request
-
Objects
- IActionResult
- IAssemblingError
- IAssemblingErrors
- IBatch
- IBatchCheckResults
- IBatchItem
- IBatchItems
- IBatchTypeClassifier
- IBatchTypeClassifierResult
- IBinarizationParams
- IBoxedBoolean
- ICharacterParams
- ICharactersParams
- ICheckmarkGroupValue
- ICheckmarkValue
- IDataSet
- IDataSetQuery
- IDataSetRecord
- IDocument
- IDocuments
- IDocumentExportResults
- IDocumentsExportResults
- IDocumentDefinitionInfo
- IDocumentDefinitionInfoArray
- IEditablePictureObject
- IExportFieldsToRedact
- IExportImageSavingOptions
- IField
- IFieldRegion
- IFieldRegions
- IFields
- IFlexiCaptureTools
- ILocalContrastParams
- IMatchedSectionInfo
- IMatchingInfo
- IPage
- IPageClassificationResult
- IPages
- IPictureObject
- IPictureObjectsInfo
- IPrincipal
- IPrincipals
- IProcessingCallback
- IProject
- IProperties
- IProperty
- IPropertyModificationInfo
- IRecordCheckResult
- IRecordset
- IRect
- IRects
- IRoutingRuleResult
- IRuleContext
- IRuleError
- IRuleErrors
- IRuleTag
- IRuleTags
- IScriptBinaryAttributes
- IScriptDefinitionContext
- ISectionDefinitionInfo
- ISectionDefinitionInfoArray
- IShadowsHighlightsParams
- IStageInfo
- IUserAttachment
- IUserAttachments
- IUserSessionInfo
- IValue
- IVARIANTArray
- TAssemlingErrorType
- TBatchItemType
- TColorToFilter
- TExportFieldType
- TExportType
- TImageCompressionType
- TPageClassificationType
- TPdfAVersion
- TPdfDocumentInfoType
- TPdfTextSearchAreaType
- TPrincipalType
- TProcessingPriority
- TPropertyType
- TRuleErrorType
- TStateType
- Sample scripts
- Internal names of recognition languages
-
Types of scripts
-
Scripts for processing interface events
-
Event handlers
- On Document Closed
- On Project Closed
- On Activate Document
- On Field Control Activate
- On Return From Task
- On User Command
- On Field Control Deactivate
- On Closing Document
- On Task Close
- On Closing Project
- On Region Change
- On Task Window Mode Changed
- On Open Document
- On Task Window Create
- On Task Reject
- On Region Control Draw
- On Task Send To Stage
- On Text Field Validating
-
Objects
- IBoolean
- IBoxedFieldControl
- IDocumentEditor
- IDocumentItem
- IDocumentItems
- IDocumentsCollection
- IDocumentsWindow
- IDrawContext
- IErrorControl
- IErrorControls
- IErrorsWindow
- IFieldControl
- IFieldRegionControl
- IFieldRegionControls
- IFormWindow
- IImageWindow
- IMainMenu
- IMainWindow
- IMenu
- IMenuItem
- IPageControl
- IPageItem
- IPageItems
- IPagesCollection
- IPoint
- ISelection
- IShellRational
- IShellRect
- IShellRects
- ITaskWindow
- ITextEditor
- IToolbar
- IToolbarButton
- IToolbars
- TCommandBarType
- TCommandID
- TDockingType
- TDocumentState
- TErrorType
- TSelectionType
- TTaskWindowMode
- TTextSize
- TUserRole
- TWorkWindowType
-
Event handlers
- User script for Web Verification Station
-
Application Programming Interface (API)
- About the ABBYY FlexiCapture Application Server Web Services API
- Using the Web Services API of the ABBYY FlexiCapture Application Server
-
References
- API Methods
- Data types
- Working with files
- Web Services Mobile API
- Web Services for user account management
- Examples of API Use
- Integrating Web Stations into third-party systems
- Configuring additional settings and customizing Web Stations
- Custom reports
-
Appendix
- Supported recognition languages
- Fonts for correct characters rendering
- Supported text types
- Supported barcode types
- Supported input formats
- Export file formats
- Date formats
- Alphabet used in regular expressions
- Protecting Document Definitions and additional modules
- Glossary
- Patents
- Third-party technologies
- Technical support
- End-User License Agreement (EULA)
Sample assembly scripts
Assembly script with conditional documents depending on the value of a field
The script in this example is used to assemble documents into document sets defined by a Document Set Definition. The Document Set Definition contains a section named Borrower's form and references to the following Document Definitions:
- Passport
- Guarantor's documents
- Co-borrower's documents
- Employer reference
The Borrower's form section includes the following fields:
- Co-borrower's name
- Loan sum
The documents that need to be included in the document set depend on the value of the Loan sum field. The script has two threshold values that determine which documents are included in the set:
- If the loan sum is less than the first threshold value, the document set only needs to contain a passport.
- If the loan sum is greater than the first threshold value but less than the second threshold value, the document set needs to contain a passport and an employer's reference.
- If the loan sum is greater than the second threshold value, the document set needs to contain a passport, an employer's reference and a guarantor's documents.
In addition to this, if the Co-borrower's name field contains a value, the document set needs to contain a co-borrower's documents.
The script below uses this logic to assembles document sets.
using System.Collections.Generic; int creditSum = 0; bool creditSumFound = false; string cocreditor = ""; int formCount = 0; string formName = "Borrower's form"; // Document Definitions used in the document set int referenceFromWorkCount = 0; string referenceFromWorkName = "Employer reference"; int guaranteeDocsCount = 0; string guaranteeDocsName = "Guarantor's documents"; int cocreditorDocsCount = 0; string cocreditorDocsName = "Co-borrower's documents"; int passportCount = 0; string passportName = "Passport"; foreach( IBatchItem item in BatchItems ) { // Find the form and determine the sum of the loan if (item.Type == TBatchItemType.BIT_Page) { if (item.AsPage.SectionName != formName) AssemblingErrors.AddCustomError("Cannot contain the following sections: " + item.AsPage.SectionName, 1); else { cocreditor = item.AsPage.Document.IndexedItemValue("Borrower's name").ToString(); string creditSumText = item.AsPage.Document.IndexedItemValue("Loan sum").ToString(); if (!int.TryParse(creditSumText, out creditSum)) AssemblingErrors.AddCustomError("Loan sum was not recognized: " + creditSumText, 1); else creditSumFound = true; formCount++; } } // Count the documents in the set else if (item.Type == TBatchItemType.BIT_Document) { if (item.AsDocument.TemplateName == referenceFromWorkName) referenceFromWorkCount++; else if (item.AsDocument.TemplateName == guaranteeDocsName) guaranteeDocsCount++; else if (item.AsDocument.TemplateName == passportName) passportCount++; else if (item.AsDocument.TemplateName == cocreditorDocsName) cocreditorDocsCount++; else AssemblingErrors.AddCustomError("The document set cannot contain the document " + item.AsDocument.TemplateName, 1); } } // Check the number of sections and documents in the set if (formCount > 1) AssemblingErrors.AddCustomError("There are too many documents of the type: " + formName, formCount); else if (formCount < 1) AssemblingErrors.AddCustomError("Missing the following documents: " + formName, 1); if (passportCount > 1) AssemblingErrors.AddCustomError("There are too many documents of the type: " + passportName, passportCount); else if (passportCount < 1) AssemblingErrors.AddCustomError("Missing the following documents: " + passportName, 1); // Check that the document set contains a co-borrower if a co-borrower name is present in the form if (cocreditor != "" && cocreditorDocsCount < 1) AssemblingErrors.AddCustomError("Missing the following documents: " + cocreditorDocsName, 1); else if (cocreditor != "" && cocreditorDocsCount > 1) AssemblingErrors.AddCustomError("There are too many documents of the type: " + cocreditorDocsName, cocreditorDocsCount); else if (cocreditor == "" && cocreditorDocsCount > 0) AssemblingErrors.AddCustomError("There are too many documents of the type: " + cocreditorDocsName, cocreditorDocsCount); // Check that the document set contains all of the document required due to the loan sum exceeding one of the thresholds if (creditSumFound) { if (creditSum > 50000) // requires an employer reference { if (referenceFromWorkCount > 1) AssemblingErrors.AddCustomError("There are too many documents of the type: " + referenceFromWorkName, referenceFromWorkCount); else if (referenceFromWorkCount < 1) AssemblingErrors.AddCustomError("Missing the following documents: " + referenceFromWorkName, 1); } if (creditSum > 500000) // requires the guarantor's documents { if (guaranteeDocsCount > 1) AssemblingErrors.AddCustomError("There are too many documents of the type: " + guaranteeDocsName, guaranteeDocsCount); else if (guaranteeDocsCount < 1) AssemblingErrors.AddCustomError("Missing the following documents: " + guaranteeDocsName, 1); } }
Assembly script that checks for missing documents
The script in this example works with the Identification Documents Document Set Definition. The Document Set Definition contains references to the following Document Definitions:
- Passport
- Driver's license
Document sets produced by the script may only include one document of each of these types but at least one document of these types.
The script below uses this logic to assemble document sets.
using System.Collections.Generic; using System; string docSetName = "Identification Documents"; int pagesCnt = 0; // List of the types documents that may be included in the set List<string> allowed = new List<string> {"Passport", "Driver's license"}; // Limit on the number of documents of each type in the set List<int> allowedCount = new List<int>{1,1}; // The number of documents detected in the set List<int> foundCount = new List<int>{0,0}; // Count the number of documents and pages in the set foreach (IBatchItem item in BatchItems) { if (item.Type == TBatchItemType.BIT_Document) { if (item.AsDocument.TemplateName == docSetName) AssemblingErrors.AddCustomError("Cannot contain a nested set", 1); else if (allowed.Contains(item.AsDocument.TemplateName)) { int i = allowed.IndexOf(item.AsDocument.TemplateName); foundCount[i]++; } } else if (item.Type == TBatchItemType.BIT_Page) pagesCnt++; } // Check the number of documents and pages if (foundCount[0] + foundCount[1] == 0) AssemblingErrors.AddCustomError("At least one identification document is required", 1); for (int i = 0; i < allowed.Count; i++) { if (foundCount[i] > allowedCount[i]) AssemblingErrors.AddCustomError("Maximum number of documents: " + allowed[i] + ": " + allowedCount[i]); } if (pagesCnt > 0) AssemblingErrors.AddCustomError("The document set cannot contain pages that do not belong to a document", pagesCnt);
1/14/2021 2:17:18 PM