This document covers starting a process from Kofax Ascent 6.1 Release scripts using the K2Rom.dll (placed in a COM wrapper) from the COM dll TextRel.dll found in Kofax. For this article, the TextRell.dll was modified to include a section to start a 2003 process.

 Article Contents

 Step 1 - Creating COM wrapper for K2Rom.dll

 Step 2 - Modify the Kofax Ascent TextRel.dll

 Step 3 - Create 2003 Process

 Step 4 - Setup a batch in Kofax Ascent for scanning and release

Step 1 - Creating COM wrapper for K2Rom.dll
To create the .NET assembly containing a public class that can be called from a COM component, follow the steps as described in this knowledge base article.

Back to Top 
Step 2 - Modify the Kofax Ascent TextRel.dll
Obtain the Visual Basic 6 code for the compiled dll from the following location: "C:\Program Files\Ascent\Source\Release\Text". This is the default installation location and may vary depending on your installation.
Note: Ensure to make a backup copy of the "Text" directory before making changes to the files as a source.
To complete the example in this article, ensure that the following pre requisites are met:
Note: Visual Basic 6 is required to compile a COM based DLL. Kofax is not .NET compatible and therefore will not be able to call from a .NET assembly. VB6 is used to demonstrate the process of modifying the COM component. Any deployment environment capable of compiling a COM component may be used.
  • Visual Basic 6 is installed
  • Locate the tutorial files NWest_1.tif and NW_Mult.tif available in the Tutorial directory
  • 2003 Project: Create a project in 2003 Studio with the following criteria
    • Project Name: KofaxTest
    • Process Name: Kofax
    • Process Data fields: "FirstName", "LasName"
  • When the user provides a K2Server name in the template, the server name must always be correct and available! No error checking regarding the server name and availability is placed in the code samples provided
Modify the DLL:
1)Open the TextRel.vbp file located in the "Source\Release\Text" directory by double clicking on the file
2)In the project explorer window
2.1)Click on the folder labeled "Forms" and open it
2.2)Double click the form labeled "frmSetup." This will open the form "frmSetup." in the Design pane in the middle of the screen


3)Select the tab control on the form (tabText). In the properties window of the control, change the Tabs property from 3 to 4. See the image below


4)Right click on the tab-control (tabText) and select "Properties"


5)For the next section, you are required to add a new Tab and then place a number of controls on the Tab and configure them.
5.1)Change the current tab to 3 and configure the properties to be as is shown in the image below:


5.2)On the blank tab, place a frame called "fraTab". Set the following properties for this frame:
Border Style0 - None
5.3)Inside the above frame, place a CheckBox with the following properties:
Alignment0 - Left Justify
CaptionUse 2003
5.4)Now, place another frame below the checkbox in the "fraTab" frame with the following properties:
BorderStyle1 - Fixed Single 2003
5.5)Inside the frame "fraK2", place a label and a text box. The label has the follow properties:
PropertyConfiguration 2003 Server
Textbox Properties
6) Double click on the checkbox (chkK2) to view the code behind the control. Place the following code in the "Click-event" of the check box:

Visual Basic 6

Private Sub chkK2_Click()

If chkK2.Value = vbChecked Then
 fraK2.Enabled = True
 txtK2ServerName.Text = GetSetting("Kofax", "K2", _"UseValue", "")
If Len(txtK2ServerName.Text) = 0 Then
 txtK2ServerName.Text = GetSetting("Kofax", "K2", _"StoreValue", "")
End If
 fraK2.Enabled = False
 txtK2ServerName.Text = ""
 SaveSetting "Kofax", "K2", "UseValue", ""
End If
End Sub

7) Place the following sub procedure in the code:
Private Sub SaveK2Settings()

If chkK2.Value = vbChecked Then
  SaveSetting "Kofax", "K2", "UseValue", _txtK2ServerName.Text
  SaveSetting "Kofax", "K2", "StoreValue", _
  SaveSetting "Kofax", "K2", "UseValue", ""
  SaveSetting "Kofax", "K2", "StoreValue",_
End If
End Sub

8) In the click events of both the "cmdOK" and the "cmdApply" buttons, add the following code to the existing code:
Call SaveK2Settings
9) Add a new class module:
9.1) Right click on the folder in the "Project Explorer" labeled "Class Module"
9.2) Select "Add>Class Module"


10) Configure the properties for the new class as shown below:


11) Add a reference to the .NET assembly created previously:
11.1) Click on "Project>References"
11.2) In the references window, enable the .NET to COM K2Rom object.


12) In the code window of the K2 class, place the following code:
Option Explicit
Private moTempClass As NetK2Rom.NetK2Rom
Private moTemp As NetK2Rom.iK2ROM

Public Sub K2StartProcess(ByRef LastName As String, _
ByRef FirstName As String)
 Set moTempClass = New NetK2Rom.NetK2Rom
 Set moTemp = moTempClass
 Dim szServerName As String
 szServerName = GetSetting("Kofax", "K2", "UseValue", "")
 Dim sDataFieldNames As String
 Dim sDataFieldValues As String
 sDataFieldNames = "FirstName,LastName"
 sDataFieldValues = FirstName & "," & LastName
 Dim bCreateProcess As Boolean
 Dim sOut As String
 With moTemp
  .Server = szServerName
  .Folio = "Kofax - " & FirstName & " " & LastName
  .Project = "KofaxTest"
  .Process = "Kofax"
  .DataFieldsCommaDelStrNames = sDataFieldNames
  .DataFieldsCommaDelStrValues = sDataFieldValues
  bCreateProcess = .CreateProcess
  sOut = .Data
  End With
End Sub

13) Open the code window for the class ASCIITextFile. Double click on the class in the "Project Explorer" window. Declare the following two variables in the ReleaseIndexes procedure:
Dim K2FirstName as String
Dim K2LastName as String

Place the following code at the end of the loop as indicated by the image below:


'If this is the FirstName or LastName, store the value
If Len(K2FirstName) = 0 Then
 K2FirstName = sValue
 K2LastName = sValue
End If


Place the following code just before the error handling starts as indicated by the image below:


'Now call the K2 Process

 Dim oK2Class As New K2
 Call oK2Class.K2StartProcess(K2LastName, K2FirstName)


14) The dll must now be recompiled. However, since the dll is registered, the dll must be de registered before the re compile can take place. The dll will be re-registered automatically once the compilation is complete with no errors.
 14.1) De-register the current DLL found in the bin directory in the Kofax Ascent installed directory (by default "C:\Program Files\Ascent\Bin")
 14.1.i) To do this, click "Start>Run"., and type in the following command (make sure no instance of Kofax Ascent using this DLL is running):
 14.1.ii) regsvr32 -u "C:\Program Files\Ascent\Bin\TextRel.dll"
 14.2) Compile the TextRel.dll. In the VB6 environment.
 14.2.i) Click on "File> Make TextRel.dll."
 14.3) The DLL has been registered when it was compiled according to the location where it was created. It therefore needs to be unregistered and moved to the bin directory of Kofax Ascent. To do this, follow the steps in a.i) above, changing only the path to the correct location where the DLL was just compiled.
 14.4) Browse to the directory where the DLL was created, copy it and paste it in the Kofax Ascent bin directory. It is advised to make a backup of the current TextRel.dll before replacing it with your newly created DLL.
 14.5) Register the DLL by doing the following:
 14.5.i) Click "Start>Run".
 14.5.ii) Type in the following command:
"regsvr32 C:\Program Files\Ascent\Bin\TextRel.dll"

Back to Top 
Step 3 - Create 2003 Process
Create a 2003 project called KofaxTest. Add a process called Kofax with two data fields, "FirstName" and "LastName", both of type string.

Add a "Default Activity" to the canvas and place a "Server Mail" event in the activity. Configure the Server Mail event to send an email to the originator. Allocate the two data fields values in the body of the email.

Once complete, export the process ensuring that there are no errors.

Back to Top 
Step 4 - Setup a batch in Kofax Ascent for scanning and release.
In this example, a batch is created which automatically recognizes the first name and the last name contained in the document. To setup the batch, do the following:
1) Open the Ascent Capture Administration module
2) Click on the "Field Types" tab on the "Definitions", and right click anywhere on the panel and a context menu will appear
3) From the context menu, select "New Field Type". The Create Field Type dialog box will appear
4) Now add Field Type with the following properties:
Data TypeVarchar
No of Chars25
5) Create a Document Class:
6) Click on the Document tab on the Definitions panel
7) Right click anywhere on the panel and a context menu will appear
8) Select New Document Class and the "Create Document Class" dialog will appear
9) Provide the document class a name - for this example we will call it K2Kofax
10) Click New to add an Index field. Add the following two index fields
10.1) "FirstName" and "LastName"
10.2) Set the field type of both to Alphanumeric_25
10.3) Set Required to True
11) Click "Ok" to create the new document class
12) Create a form type by right-clicking on the K2Kofax document type just created and select New Form Type from the context menu.
13) Give the new form type the name K2FormType
14) Select the checkbox for Fixed Number of pages and add a 1 to the list below it (see image). Now click "OK" to close the context menu.


15) Click on the drop-down arrow and ensure the option "Software Import" is selected as indicated:


16) Right click on the newly created form type in the definitions window and select Add Sample Pages from the context menu.
17) Browse to the file called NWest_1.tif (located in the tutorial directory of the Kofax Ascent installation)
18) Select the file NWest_1.tif
19) You will now see the page displayed
20) To continue, an image cleanup filter profile must be created. To do this, select "Edit Image Cleanup Profiles". The Image Cleanup Profiles context menu will appear.
21) Enable the checkbox next to "Horizontal Line removal". Enter the settings as displayed in the image:


22) Enable the checkbox next to "Vertical line removal". Enter the settings as in the image below


23) Click on "Save As" and save the profile as Tutorial - Line Removal
24) Create a recognition profile. Click on "Edit >Recognition Profile". The Recognition Profile context menu will appear
25) From the "Name" dropdown list, select Kofax High Performance ICR Zonal
26) Select the Print Type: "Handprint"
27) Select the Content Alphanumeric with the character set A-Za-z
28) Set the Trigram mode to "Off" and enable the setting "Logical content"
29) In the image clean up profile, select Tutorial - Line Removal (the clean up profile we just created)
30) Now click "Save As" and save this recognition profile as Tutorial - Boxed Letters
31) When done, the profile will look as follows:


32) The advanced settings must look as follow:

33) Click "Close" to close the context menu
34) Select the Create Index Zone icon ( ) from the menu at the top. Draw a box around the "First Name" section on the sample page as follows:


35) A context menu will appear. Select "FirstName" from the "Associated Field" drop down list. Select "Auto Recognition" and select "Tutorial - Boxed Letters" from the "Recognition Profiles" dropdown list
36) Repeat step 33 for the "Last Name" area, this time selecting "LastName" from the "Associated Field" dropdown list and Tutorial - Boxed Letters from the "Recognition Profiles" dropdown list
37) View the preview, an example preview is shown below:


38) Create a batch class. Select the "Batch" tab on the "Definitions" panel. Right click anywhere on the panel and select "New Batch Class" from the context menu.
39) Call the Batch Class K2Batch. Click "New" to add a batch field. Call it Site ID, field type Alphanumeric_25, and Default value {Site ID}.
40) Under the Queues tab, select the following in sequence:
Queues Settings
Recognition Server
41) Under the "Separation and Form Identification" tab, select Kofax fixed pages.
42) Click on the "Queues" tab, select "Scan" and then click on "Properties". Set the properties as follows:


43) Click "OK" to save and close the properties window
44) Click "OK" to close the "Batch Class" properties window
45) Right click on the batch class K2Batch and select "Insert Document Class" from the context menu
46) Select K2Kofax from "Insert Document Class" list
47) Now setup the release script to use. Right click on the "Document Class" K2Kofax which you just added to the batch class. From the context menu, select "Release Scripts"
48) Now select "Ascent Capture Text" from the list on the left and add it to the "Assigned Release" scripts list on the right
49) The template will appear. In the name enter K2KofaxRelease
50) Under the "Index Storage" tab, browse to a working directory where the output files will be saved. Call the file K2Test.txt
51) Under "Document Storage" tab, select Release Image files and browse to a directory where the image files will be released to
52) Under the 2003 tab, select Use 2003, and place the server name in the textbox
53) Click "OK" to save and click "Close"
54) Publish the batch. To publish the batch right clicking on the batch (K2Batch). Select "Publish" from the context menu. From the "Publish" dialog box, publish the document, ensuring that there were no errors. Refer to the AC_6_1_Learning_Ascent_Capture_Guide.pdf on correcting possible errors.
Since the batch class has been created, a few final steps must be performed. A batch must be scanned and run through the recognition server. Once the data has been validated it can then be released.
Scan Module:
1) Open the "Scan" module of Kofax Ascent
2) In the "Create Batch" dialog box, select K2Batch from the batch class dropdown list
3) Give the Batch a descriptive name. For this example use K2BatchTest1
4) Click the "Scan" button
5) Browse to the location where the NW_Multi.tif file is stored (by default in the tutorial directory under the Ascent installed folder). Select the file and click "Open"
6) Select "Batch>Close" from the menu. When prompted if you are sure, select "Yes"
7) Close the "Scan" module
Recognition Server Module:
1) Open the "Recognition" module of Kofax Ascent
2) The recognition server will scan through the batch. Close the module when the recognition server has completed its task
Validation Module:
1) Open the "Validation" module of Kofax Ascent
2) The Open Batch dialog should appear. From the dialog, select K2BatchTest1 and click "Ok"
3) Ensure that the data is correct. By pressing TAB, you can quickly run through the document and see that the data is correct. Once you have checked all the data, you will be prompted if you whish to close the batch. Select "Ok", and close the validation module
Release Module:
Note: The user under which the Release module is run must be the same user who starts the 2003 process. Ensure that this user has the appropriate rights to start the process.
1) Open the "Release" module of Kofax Ascent
2) The "Release" module will automatically run through each document and release it to the file system to the directory specified earlier. Once the document is released to the directory a new 2003 process instance will be started
3) For each document that is released an email will be received by the destination user

Back to Top