> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install the ABBYY FlexiCapture connector on a Pega server: import the JAR, create a library with packages and static variables, and define functions.

To install the PEGA, you need to:

[Import a connector to the Pega server](#import)

[Create a library](#lib)

[Create required functions](#func)

## <a id="import" />Importing a connector to the Pega server

To import the connector to the server:

1. Open **Dev Studio** and click **Configure → Application → Distribution → Import**.

   <Frame>
     <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega1.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=a341f96a004c8a19fb49207d18680709" alt="Screenshot of Pega Dev Studio with the Configure menu open, showing the Application → Distribution → Import path being selected to import the connector." width="935" height="329" data-path="images/flexi-capture/connectors/Pega1.png" />
   </Frame>

2. Load the **abbyy.flexicapture.webapi.client.jar** file on to the server.

3. Open the **Pega Self-Service Portal** and click **Restart Server**.

<Frame>
  <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega2.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=eecde34cbec1e5bd944b2b7b9ae52933" alt="Screenshot of the Pega Self-Service Portal Operations page with the Restart Server button highlighted to restart the application server." width="537" height="297" data-path="images/flexi-capture/connectors/Pega2.png" />
</Frame>

## <a id="lib" />Creating a library

To create a library:

1. Click **Records → Technical → Library → Create**.

2. In the **Label** field of the **Create Library** tab, specify a name for the library (e.g. *ABBYY*) and fill in the **Identifier** field. Make sure that the library is being created within the context of your application and then click **Create and open**.

   <Frame>
     <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega52.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=3ca766b1ed9d2c5b38309ae1a1712219" alt="Screenshot of the Pega Create Library form with ABBYY entered in the Label and Identifier fields and FlexiCapture for Invoices selected as the application context." width="1227" height="429" data-path="images/flexi-capture/connectors/Pega52.png" />
   </Frame>

3. On the **Packages** tab, add the following packages:

   * *java.util.*\*
   * *java.nio.file.*\*
   * *java.net.*\*
   * *java.lang.*\*
   * *java.util.stream.*\*
   * *org.apache.commons.lang3.*\*
   * *abbyy.flexicapture.webapi.client.*\*
   * *abbyy.flexicapture.webapi.client.api.*\*
   * *abbyy.flexicapture.webapi.client.models.*\*

   <Frame>
     <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega53.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=0176835eae98534710c3ae9402e84117" alt="Screenshot of Pega Dev Studio on the library Packages tab, listing the nine Java packages to include, including the abbyy.flexicapture.webapi.client packages, with the Generate Library button below." width="601" height="702" data-path="images/flexi-capture/connectors/Pega53.png" />
   </Frame>

4. On the **Static Variables** tab, create the following string variables:

   * *baseUri*
   * *tenantName*
   * *userName*
   * *Password*
   * *multiFileProjectName*
   * *singleFileProjectName*

   <Frame>
     <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega54.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=eccb393f811a02438cfc1de83cf4032c" alt="Screenshot of Pega Dev Studio on the library Static Variables tab, showing the baseUri, tenantName, userName, password, multiFileProjectName, and singleFileProjectName String variables and their sample values." width="844" height="412" data-path="images/flexi-capture/connectors/Pega54.png" />
   </Frame>

5. Click **Save** and then click **Generate Library**.

## <a id="func" />Creating a function

A function contains Java code that is executed when the function is called from other Pega objects. The input and output parameters of a function are specified on the **Parameters** tab, while exceptions are specified on the **Imports & Exceptions** tab.

To create a function:

1. Click **Records → Technical → Function → Create** and fill in the **Label** and **Identifier** fields.
2. In the **Library** field, specify the name of the library you created earlier.
3. In the **Parameters** section, specify the following two input parameters:

| **Name**        | **Java type** |
| --------------- | ------------- |
| *FileName*      | *String*      |
| *Base64Content* | *String*      |

4. Make sure that the function is being created within the context of your application and click **Create and open**.

   <Frame>
     <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega55.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=31cfe52be7c6f5dafac9590265e87b98" alt="Screenshot of the Pega Create Function form with SendForProcessing in the Label field, the ABBYY library selected, the fileName and base64Content String parameters listed, and FlexiCapture for Invoices selected as the application context." width="819" height="471" data-path="images/flexi-capture/connectors/Pega55.png" />
   </Frame>

5. In the window that opens, on the **Parameters** tab, specify *int*, *string* or *boolean* as the data type in the **Java data type** field:

   <Frame>
     <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega56.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=3a4b847cb643cb18d26c637c4bdfbede" alt="Screenshot of Pega Dev Studio on the function Parameters tab, showing the fileName and base64Content String input parameters and int entered as the Java data type in the Output section." width="1455" height="667" data-path="images/flexi-capture/connectors/Pega56.png" />
   </Frame>

6. Click the **Imports & Exceptions** tab and type *Exception* in the **Exceptions thrown** section.

   <Frame>
     <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega57.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=3be1a89418a95c69bbb6d6ab3621aca7" alt="Screenshot of Pega Dev Studio on the function Imports & Exceptions tab, showing Exception entered in the Exceptions thrown section." width="571" height="288" data-path="images/flexi-capture/connectors/Pega57.png" />
   </Frame>

7. Go back to the **Java** tab, insert the code for the function in the **Java source** field, select the **Function ready to be compiled?** option, save your changes, and click **Generate function**.

<Note>
  The code for the function can be copied from the java file, which you can find in *%Installation Path%\Connector for FlexiCapture as a Service with verification\Samples\Code examples\Pega Functions*.
</Note>

<Frame>
  <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega58.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=d81b7efb0a7f8d87df6ef3325ea26832" alt="Screenshot of Pega Dev Studio on the function Java tab, showing the Function ready to be compiled option selected, the Generate function button, and the Java source code that creates a FlexiCapture batch and returns its identifier." width="1014" height="720" data-path="images/flexi-capture/connectors/Pega58.png" />
</Frame>

To implement a single-document processing scenario, you need to:

1. [Create a set of functions to be used for the processing of a single document](/flexi-capture/connectors/pega/pega-func-one-doc).
2. [Create general functions](/flexi-capture/connectors/pega/pega-func-other).
3. [Create a single-document processing case](/flexi-capture/connectors/pega/pega-one-doc-case).
4. [Configure the user interface](/flexi-capture/connectors/pega/pega-config-ui-1).
5. [Create a set of activities for your single-document processing case](/flexi-capture/connectors/pega/pega-activities-one-doc).
6. [Create a set of data transforms for your single-document processing case](/flexi-capture/connectors/pega/pega-dt-one-doc).
7. [Create a flow action](/flexi-capture/connectors/pega/pega-flow-action).
8. [Create data types for your single-document processing case](/flexi-capture/connectors/pega/pega-one-doc-data-type).

To implement a multi-document processing scenario, you need to:

1. [Create a set of functions to be used for the processing of multiple documents](/flexi-capture/connectors/pega/pega-func-multiple-docs).
2. [Create general functions](/flexi-capture/connectors/pega/pega-func-other).
3. [Create a multi-document processing case](/flexi-capture/connectors/pega/pega-many-docs-case).
4. [Create HTML fragments](/flexi-capture/connectors/pega/pega-html).
5. [Create a set of activities for your multi-document processing case](/flexi-capture/connectors/pega/pega-activities-many-docs).
6. [Create a set of data transforms for your multi-document processing case](/flexi-capture/connectors/pega/pega-dt-many-docs).
7. [Create a flow action](/flexi-capture/connectors/pega/pega-flow-action).
8. [Create data types for your multi-document processing case](/flexi-capture/connectors/pega/pega-many-docs-data-types).
