Skip to main content
The following samples show common export tasks in ABBYY FlexiCapture, such as reading field values, saving page images, exporting tables, and handling export results. Most samples are provided in both VBScript and JScript, and some include an external component written in Visual Basic or C#.

Get field values during export

This sample gets the value of a field during export. You can use this value to name the files that images or data are exported into. If the document does not contain the field, an error occurs. The structure of the document to be exported:
The following VBScript sample gets the field values:
The following JScript sample does the same:

Export page images

This example exports images of all document pages using a chosen file format, color scheme, and resolution. Each page is saved to a separate file. The files in this example are named page1.tif, page2.tif, and so on. You can change the file-naming mechanism — for example, base file names on the value of a field. The following VBScript sample exports the page images:
The following JScript sample does the same:

Export a table

This example exports a table to a *.txt file. The following VBScript sample exports the table:
The following JScript sample does the same:

Export a document of any nesting level

This example exports fields of a document of any nesting level using custom functions from the global export module. To export document fields of variable nesting, use an external COM component, as shown in the following example.

Core export code

Add this call to the document export script. The following VBScript calls the export function:
The equivalent JScript call:

Global export module functions

The global export module defines the following functions. The VBScript implementation:
The JScript implementation:

Use an external COM component

Call an external COM component from the export script. This approach is useful for exporting document fields of variable nesting. The following VBScript calls the component:
The equivalent JScript call:

Exporter class code in Visual Basic

This is the Exporter class code from the AutomationExport project used in the preceding scripts.

Use a .NET component written in C#

1

Create a ClassLibrary project

Create a project of type ClassLibrary.
2

Add the ControllerInterop.dll reference

Add ControllerInterop.dll to the project References. ABBYY.FlexiCapture appears in the References list, and all the interfaces of the script objects become available in the project.
3

Define the dispinterface, class, and ProgId

Define the dispinterface and the class that implements this interface, as well as the ProgId. This makes it possible to work with the .NET component from script code just like with ActiveX.
4

Register the generated type library

After building the project, register the generated type library. To do this automatically, enable the corresponding option in the project properties.
5

Call the component from the export code

From the export code, call the component method in the usual way, as shown in the following example.
The following VBScript calls the component:
The equivalent JScript call:
The following C# code implements such a component:

Write an export handler

This sample demonstrates a simple export handler that saves information about exported documents and export results to text files. It uses two text files: one for the list of successfully exported documents and one for the list of documents that returned errors during export. The following VBScript sample handles the export results:
The equivalent JScript sample:

Access source files in common office formats

This sample script saves the source files when exporting documents. The source files must be in one of the supported common office formats and must have unique names to avoid naming conflicts.