> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartdataentryadapter.md).

# SmartDataEntryAdapter

Namespace: **Wisej.AI.Adapters**

Assembly: **Wisej.AI** (3.5.0.0)

* [SmartAdapter](/ai/components/api/smartadapter.md)
  * [SmartDataEntryAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartdataentryadapter.md)

Enhances all the controls in the associated container with the AI-powered capability to extract structured data from unstructured text.

{% tabs %}
{% tab title="C#" %}

```csharp
public class SmartDataEntryAdapter : SmartAdapter, IExtenderProvider
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class SmartDataEntryAdapter
    Inherits SmartAdapter
    Implements IExtenderProvider
```

{% endtab %}
{% endtabs %}

Works with:

* AzureAI/OpenAI gpt-4
* AzureAI/OpenAI gpt-4o
* AzureAI/OpenAI gpt-3.5
* AzureAI/Anthropic Claude
* Google Gemini
* Llama3:8b and 70b

Supports several types of sources for the input text: Clipboard (text or image), PDF stream, Text, Word, Excel. Uses the [Tesseract](https://docs.wisej.com/api?q=wisej.ext.tesseract.tesseract) extension to run the OCR text extraction on the user's browser in JavaScript.

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) SmartDataEntryAdapter()

Initializes a new instance of the [SmartDataEntryAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartdataentryadapter.md) class.

### ![](/files/ptrKjmmRoQB76pvrIqh0) SmartDataEntryAdapter(container)

Initializes a new instance of the [SmartDataEntryAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartdataentryadapter.md) class with the specified container.

| Name          | Type                                                                                 | Description                                                                                                                             |
| ------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| **container** | [IContainer](https://docs.microsoft.com/dotnet/api/system.componentmodel.icontainer) | An [IContainer](https://docs.microsoft.com/dotnet/api/system.componentmodel.icontainer) that represents the container of the component. |

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) ExcludeReadOnly

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Gets or sets a value indicating whether read-only controls should be excluded. (Default: `False`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) MaxIterations

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the maximum number of times the adapter will try to use the available tools to complete the missing values. (Default: `2`)

If the adapter was not provided any tool, this property is ignored since it will not try to resolve missing values.

### ![](/files/ptrKjmmRoQB76pvrIqh0) UseOCR

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Gets or sets a value indicating whether OCR should be used for image processing. (Default: `False`)

## Methods

### ![](/files/KL0Ik37djZRr8a07Wopd) Dispose(disposing)

Releases the unmanaged resources used by the [SmartDataEntryAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartdataentryadapter.md) and optionally releases the managed resources.

| Parameter     | Type                                                            | Description                                                                                      |
| ------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| **disposing** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true to release both managed and unmanaged resources; false to release only unmanaged resources. |

### ![](/files/ptrKjmmRoQB76pvrIqh0) FromClipboardAsync()

Asynchronously processes data from the clipboard and extracts structured data.

**Returns:** [Task](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task). A task representing the asynchronous operation.

**Throws:**

* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  Thrown when the SmartAdapter is busy.

### ![](/files/ptrKjmmRoQB76pvrIqh0) FromImageAsync(image)

Asynchronously processes the provided image and extracts structured data.

| Parameter | Type                                                                | Description                |
| --------- | ------------------------------------------------------------------- | -------------------------- |
| **image** | [Image](https://docs.microsoft.com/dotnet/api/system.drawing.image) | The image to be processed. |

**Returns:** [Task](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task). A task representing the asynchronous operation.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the image is null.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  Thrown when the SmartAdapter is busy.

### ![](/files/ptrKjmmRoQB76pvrIqh0) FromStreamAsync(stream, streamType)

Asynchronously processes the provided stream and extracts text and image data. If an image is detected without associated text, the method attempts to perform OCR to extract text.

| Parameter                                       | Type                                                             | Description                                                                                                   |
| ----------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **stream**                                      | [Stream](https://docs.microsoft.com/dotnet/api/system.io.stream) | The stream containing the input data.                                                                         |
| **streamType** ![](/files/52BqKf9SltWQ97FbQSBF) | [String](https://docs.microsoft.com/dotnet/api/system.string)    | An optional string that specifies the type of data being processed. If not provided, a default value is used. |

**Returns:** [Task](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task). A task representing the asynchronous operation.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the stream is null.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  Thrown when the SmartAdapter is busy.

### ![](/files/ptrKjmmRoQB76pvrIqh0) FromTextAsync(text)

Asynchronously processes the provided text and extracts structured data.

| Parameter | Type                                                          | Description               |
| --------- | ------------------------------------------------------------- | ------------------------- |
| **text**  | [String](https://docs.microsoft.com/dotnet/api/system.string) | The text to be processed. |

**Returns:** [Task](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task). A task representing the asynchronous operation.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the text is null.
* [InvalidOperationException](https://docs.microsoft.com/dotnet/api/system.invalidoperationexception)\
  Thrown when the SmartAdapter is busy.

### ![](/files/ptrKjmmRoQB76pvrIqh0) GetFieldName(component)

Gets the name of the field to extract for the specified component.

| Parameter     | Type                                                                       | Description                                    |
| ------------- | -------------------------------------------------------------------------- | ---------------------------------------------- |
| **component** | [IWisejComponent](https://docs.wisej.com/api?q=wisej.core.iwisejcomponent) | The component for which to get the field name. |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string). The name of the field to extract.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the component is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) GetFieldPrompt(component)

| Parameter     | Type                                                                       | Description |
| ------------- | -------------------------------------------------------------------------- | ----------- |
| **component** | [IWisejComponent](https://docs.wisej.com/api?q=wisej.core.iwisejcomponent) |             |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string).

### ![](/files/ptrKjmmRoQB76pvrIqh0) GetFieldRectangle(component)

Gets the rectangle that defines the area of the field to extract for the specified component.

| Parameter     | Type                                                                       | Description                                         |
| ------------- | -------------------------------------------------------------------------- | --------------------------------------------------- |
| **component** | [IWisejComponent](https://docs.wisej.com/api?q=wisej.core.iwisejcomponent) | The component for which to get the field rectangle. |

**Returns:** [Nullable\<Rectangle>](https://docs.microsoft.com/dotnet/api/system.nullable-1). The rectangle that defines the area of the field to extract.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the component is null.

### ![](/files/KL0Ik37djZRr8a07Wopd) OnParseValue(e)

Raises the [ParseValue](#parsevalue) event.

| Parameter | Type                                                                                                  | Description                                                                                                                                   |
| --------- | ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [ParseValueArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdataentryadapter+parsevalueargs) | The [ParseValueArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdataentryadapter.parsevalueargs) instance containing the event data. |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnUpdateField(e)

Raises the [UpdateField](#updatefield) event.

| Parameter | Type                                                                                                    | Description                                                                                                                                     |
| --------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [UpdateFieldArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdataentryadapter+updatefieldargs) | The [UpdateFieldArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdataentryadapter.updatefieldargs) instance containing the event data. |

### ![](/files/KL0Ik37djZRr8a07Wopd) RunAsyncCore(control)

Asynchronously runs the core logic of the adapter on the specified control.

| Parameter   | Type                                                      | Description             |
| ----------- | --------------------------------------------------------- | ----------------------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) | The control to process. |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation.

### ![](/files/ptrKjmmRoQB76pvrIqh0) SetFieldName(component, value)

Sets the name of the field to extract for the specified component.

| Parameter     | Type                                                                       | Description                                    |
| ------------- | -------------------------------------------------------------------------- | ---------------------------------------------- |
| **component** | [IWisejComponent](https://docs.wisej.com/api?q=wisej.core.iwisejcomponent) | The component for which to set the field name. |
| **value**     | [String](https://docs.microsoft.com/dotnet/api/system.string)              | The name of the field to extract.              |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the component is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) SetFieldPrompt(component, value)

Sets the prompt to instruct the AI on how to extract the value for the field for the specified component.

| Parameter     | Type                                                                       | Description                                                              |
| ------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| **component** | [IWisejComponent](https://docs.wisej.com/api?q=wisej.core.iwisejcomponent) | The component for which to set the field prompt.                         |
| **value**     | [String](https://docs.microsoft.com/dotnet/api/system.string)              | The prompt to instruct the AI on how to extract the value for the field. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the component is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) SetFieldRectangle(component, value)

Sets the rectangle that defines the area of the field to extract for the specified component.

| Parameter     | Type                                                                            | Description                                                  |
| ------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| **component** | [IWisejComponent](https://docs.wisej.com/api?q=wisej.core.iwisejcomponent)      | The component for which to set the field rectangle.          |
| **value**     | [Nullable\<Rectangle>](https://docs.microsoft.com/dotnet/api/system.nullable-1) | The rectangle that defines the area of the field to extract. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the component is null.

## Events

### ![](/files/ptrKjmmRoQB76pvrIqh0) ParseValue

[ParseValueEventHandler](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdataentryadapter+parsevalueeventhandler) Occurs when a value is parsed from the input data.

### ![](/files/ptrKjmmRoQB76pvrIqh0) UpdateField

[UpdateFieldEventHandler](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdataentryadapter+updatefieldeventhandler) Occurs when a field is updated with a new value.

## Implements

| Name                                                                              | Description                                |
| --------------------------------------------------------------------------------- | ------------------------------------------ |
| [IToolProvider](/ai/components/api/smarttool/wisej.ai.smarttool.itoolprovider.md) | Represents a provider that supplies tools. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartdataentryadapter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
