---
title: "Extract text position from PDF on Android | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/extraction/text-position/"
md_url: "https://www.nutrient.io/guides/android/extraction/text-position.md"
last_updated: "2026-06-09T10:26:34.428Z"
description: "Nutrient Android SDK’s PdfDocument class can be used to get the position of text on a page."
---

# Extract the text position from PDFs on Android

Nutrient Android SDK’s [`PdfDocument`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-pdf-document/index.html) class can be used to get the position of text on a page.

[`getPageTextRects()`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-pdf-document/get-page-text-rects.html) returns a list of `RectF` coordinates split into consecutive blocks of characters based on the passed range of character indexes for the page.

Here’s an example showing how to get the text positions for each text block on a page:

### KOTLIN

```kotlin

val pageIndex = 0
val pageText = document.getPageText(pageIndex)

for (textRect in document.getPageTextRects(pageIndex, 0, pageText.length)) {
    // Get the text for the block.
    val blockText = document.getPageText(pageIndex, textRect)
    // And the position/area of the block is `textRect`....
}

```

### JAVA

```java

final int pageIndex = 0;
final String pageText = document.getPageText(pageIndex);

for (final RectF textRect : document.getPageTextRects(pageIndex, 0, pageText.length())) {
    // Get the text for the block.
    final String blockText = document.getPageText(pageIndex, textRect);
    // And the position/area of the block is `textRect`....
}

```

For more granular character positions or word positions, the arguments of [`getPageTextRects()`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-pdf-document/get-page-text-rects.html) can be tweaked to specify the character offset and length desired. For example, use the following to get the position of the first instance of the word PSPDFKit on the first page of a document:

### KOTLIN

```kotlin

val pageIndex = 0
val textPosition = document.getPageText(pageIndex).indexOf("PSPDFKit")
val textRects = document.getPageTextRects(pageIndex, textPosition, "PSPDFKit".length, true)

```

### JAVA

```java

final int pageIndex = 0;
final int textPosition = document.getPageText(pageIndex).indexOf("PSPDFKit");
final List<RectF> textRects = document.getPageTextRects(pageIndex, textPosition, "PSPDFKit".length(), true);

```
---

## Related pages

- [PDF extraction library for Android](/guides/android/extraction.md)
- [Easily extract text from PDFs on Android](/guides/android/features/text-extraction.md)
- [Extract metadata from PDFs on Android](/guides/android/extraction/metadata.md)
- [Effortlessly parse PDF content on Android](/guides/android/extraction/parse-content.md)
- [Extract pages from PDFs on Android](/guides/android/extraction/page-extraction.md)
- [Extract selected text from PDFs on Android](/guides/android/extraction/selected-text.md)

