# OcrResult

Artifact: [androidx.pdf:pdf-viewer](https://developer.android.com/jetpack/androidx/releases/pdf) [View Source](https://cs.android.com/search?q=file:androidx/pdf/ocr/OcrProvider.kt+class:androidx.pdf.ocr.OcrResult) Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

*** ** * ** ***


```
@ExperimentalPdfApi
interface OcrResult
```

<br />

*** ** * ** ***

Represents the complete result of an OCR process, providing methods to query text spatially.

This interface manages the mapping between the raw recognized text and its visual coordinates in the original image.

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText` | `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getAllText()()` Returns all recognized text and its corresponding bounding boxes. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/graphics/Rect.html>>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getSearchBounds(kotlin.String,kotlin.Boolean)(searchTerm: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, ignoreCase: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Searches for occurrences of the `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getSearchBounds(kotlin.String,kotlin.Boolean)` and returns their bounding boxes. |
| `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText` | `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getText(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)(startX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, startY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, endX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, endY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the text and its bounding boxes within the selection range defined by two points. |
| `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText?` | `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getWordAt(kotlin.Int,kotlin.Int)(x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the word and its bounding boxes at the specified coordinate. |

## Public functions

### getAllText

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
fun getAllText(): OcrText
```

Returns all recognized text and its corresponding bounding boxes.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText` | An `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText` object containing all recognized text in the image. |

### getSearchBounds

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
@WorkerThread
fun getSearchBounds(searchTerm: String, ignoreCase: Boolean = true): List<List<Rect>>
```

Searches for occurrences of the `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getSearchBounds(kotlin.String,kotlin.Boolean)` and returns their bounding boxes.

| Parameters |
|---|---|
| `searchTerm: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The string to search for. |
| `ignoreCase: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | `true` to ignore case when searching, `false` otherwise. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/graphics/Rect.html>>` | A list of lists of `https://developer.android.com/reference/android/graphics/Rect.html` objects, where each inner list represents the visual bounding boxes for one occurrence of the search term. |

### getText

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
fun getText(startX: Int, startY: Int, endX: Int, endY: Int): OcrText
```

Returns the text and its bounding boxes within the selection range defined by two points.

The selection range is determined by finding the closest characters to the provided start and end coordinates.

| Parameters |
|---|---|
| `startX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The starting X coordinate, relative to image dimensions. |
| `startY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The starting Y coordinate, relative to image dimensions. |
| `endX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The ending X coordinate, relative to image dimensions. |
| `endY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The ending Y coordinate, relative to image dimensions. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText` | An `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText` object containing the selected text and its bounds. |

### getWordAt

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
fun getWordAt(x: Int, y: Int): OcrText?
```

Returns the word and its bounding boxes at the specified coordinate.

If the (`https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getWordAt(kotlin.Int,kotlin.Int)`, `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrResult#getWordAt(kotlin.Int,kotlin.Int)`) coordinate lies within a word, that entire word is returned. If the point is on whitespace or outside any recognized text, `null` is returned.

| Parameters |
|---|---|
| `x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The X coordinate to query, relative to image dimensions. |
| `y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Y coordinate to query, relative to image dimensions. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText?` | An `https://developer.android.com/reference/kotlin/androidx/pdf/ocr/OcrText` object containing the word at the point, or `null` if no word is found. |