---
title: "Find text in the uploaded PDF, with page sizes"
method: GET
path: "/api/v1/documents/{id}/text"
tags: ["Documents"]
---

# Find text in the uploaded PDF, with page sizes

`GET /api/v1/documents/{id}/text`

## Request

- Base URL: `https://api.korala.ai`
- URL: `https://api.korala.ai/api/v1/documents/{id}/text`
- Auth: one of:
  - API key in header `X-API-Key`
  - `bearer` (a scheme the document does not define)

Returns every page size and, when `text` is given, each place it appears: page, box in points from the top-left, and the line it sits on. Flat PDFs carry no form fields to read positions from; this is how a caller that cannot see the page finds the signature line.

## Path parameters

- `id` string, required

## Query parameters

- `text` string
- `texts` string[]

## Response `200`

- DocumentTextDto
  - `pages` PageSizeDto[], required: The pages that were searched: at most the first 150
    - `pageNumber` number, required
    - `width` number, required: Page width in PDF points
    - `height` number, required: Page height in PDF points
    - `rotated` boolean: True for a page stored rotated. Text positions on it cannot be trusted, so fields there need coordinates.
  - `pageCount` number, required: Pages in the document, searched or not
  - `matches` TextMatchDto[], required
    - `text` string, required: The phrase this match is for, as it was asked
    - `occurrence` number, required: Which match of that phrase this is, counting from 1 in reading order
    - `pageNumber` number, required
    - `xPosition` number, required: Left edge of the matched text, in points from the page left
    - `yPosition` number, required: Top edge of the matched text, in points from the page top
    - `width` number, required
    - `height` number, required
    - `line` string, required: The whole line the match sits on, to tell matches apart
  - `totalMatches` number, required: Matches found for all the phrases together, which may exceed those listed; `counts` has the total for each phrase
  - `counts` TextMatchCountDto[], required: How often each phrase was found. A phrase with no matches is listed with 0, so nothing asked for goes unanswered
    - `text` string, required
    - `total` number, required
  - `hasText` boolean, required: False when the PDF has no text layer (a scan): nothing can be found in it, so fields need coordinates

## Other responses

- `400`: Malformed UUID in path parameter (`id`).

---

[API](https://skmtc.dev/korala/apis/korala-public-api.md) · [All operations](https://skmtc.dev/korala/apis/korala-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/korala/apis/korala-public-api/revisions/5c4d7810c507?raw)
