> For the complete documentation index, see [llms.txt](https://ftech.gitbook.io/focr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ftech.gitbook.io/focr/android-focr-sdk/2.-focr-sdk-features.md).

# 2. FOCR SDK Features

## Init gateway

Contact us for get `app_id` & `secret_key`

{% tabs %}
{% tab title="Java" %}

```java
OCRManager.initGateway(appId, secretKey, new IInitGatewayCallback() {
  @Override
  public void onSuccess() {

  }

  @Override
  public void onFail(@Nullable AppException error) {

  }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```java
OCRManager.initGateway(appId, secretKey, object : IInitGatewayCallback {
  override fun onSuccess() {

  }

  override fun onFail(error: AppException?) {

  }
})
```

{% endtab %}
{% endtabs %}

## Register OCR callback

**After registration, the SDK will return the corresponding status in the callback**

<table><thead><tr><th width="241">Status</th><th>Description</th></tr></thead><tbody><tr><td>onStart</td><td>Called at start OCR</td></tr><tr><td>onSuccess</td><td>Called when return result</td></tr><tr><td>onFail</td><td>Called when an error occurs in process</td></tr></tbody></table>

{% tabs %}
{% tab title="Java" %}

```java
OCRManager.registerOCRCallback(new IOCRCallback() {
  @Override
  public void onStart() {

  }

  @Override
  public void onFail(@Nullable AppException error) {

  }

  @Override
  public void onSuccess(@NonNull OCRData result) {

  }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
OCRManager.registerOCRCallback(object : IOCRCallback {
  override fun onStart() {

  }


  override fun onFail(error: AppException?) {

  }

  override fun onSuccess(result: OCRData) {

  })
})
```

{% endtab %}
{% endtabs %}

## Get Config

* Get list config used to ocr param
* When sucess, result is `listConfig`, it will be called on `onSuccess()` in callback
* When fail, it will called on `onFail()` in callback

{% tabs %}
{% tab title="Java" %}

```java
OCRManager.getConfig(new IOCRConfigCallback() {
    @Override
    public void onSuccess(@NonNull List<OCRConfigData> listConfig) {
        
    }

    @Override
    public void onFail(@Nullable AppException error) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
OCRManager.getConfig(object : IOCRConfigCallback {
    override fun onSuccess(listConfig: List<OCRConfigData>) {

    }

    override fun onFail(error: AppException?) {
    
    }
})
```

{% endtab %}
{% endtabs %}

## Start OCR

* Used to start OCR
* When successful start, it will be called on `onStart()` in callback
* When have result `result` will be return on `onSuccess` in callback.
* When fails, it will be processed at callback `onFail()` in callback.

{% tabs %}
{% tab title="Java" %}

```java
//use file
OCRManager.startOCR(documentType, responseFormat, toMathMl, file); 
...
//use file path
OCRManager.startOCR(documentType, responseFormat, toMathMl, absoluteFilePath); 
```

{% endtab %}

{% tab title="Kotlin" %}

```java
//use file
OCRManager.startOCR(documentType, responseFormat, toMathMl, file) 
...
 //use file path
OCRManager.startOCR(documentType, responseFormat, toMathMl, absoluteFilePath)
```

{% endtab %}
{% endtabs %}

## Export OCR data

* Used to export data OCR to csv or excel file
* `exportType` is `OCRExportType.CSV` or `OCRExportType.EXCEL`
* When export success `data` will be return on `onSuccess` in callback.
* When fails, it will be processed at callback `onFail()` in callback

{% tabs %}
{% tab title="Java" %}

```java
OCRManager.export(requestId, exportType, new IExportCallback() {
    @Override
    public void onSuccess(@NonNull String data) {
        
    }

    @Override
    public void onFail(@Nullable AppException error) {

    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
OCRManager.export(requestId, exportType, object : IExportCallback {
    override fun onSuccess(data: String) {

    }

    override fun onFail(error: AppException?) {
    
    }
})
```

{% endtab %}
{% endtabs %}

## UI Preview OCR data

```xml
<ai.ftech.focrsdk.sdk.FOCRView
    android:id="@+id/ocrView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
```

Then set OCRData from onSuccess to view&#x20;

```java
  ocrView.setData(ocrData)
```


---

# 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:

```
GET https://ftech.gitbook.io/focr/android-focr-sdk/2.-focr-sdk-features.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
