# TextApi.extract()

```ts
extract(pageIndex: number): Promise<string>
```

All text on a page, as a string; lines end with `\n`. Needs the `extract` feature.

- Kind: method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `pageIndex` | `number` | Zero-based page index. |

Returns `Promise<string>`: Lines end with `\n`.

Throws:

- `INVALID_ARGUMENT` — a page index out of range.
- `PAGE_ERROR` — the page or its text could not be loaded.
- `DOCUMENT_CLOSED` — the document has been closed.
- `FEATURE_NOT_LICENSED` — the license lacks `extract`.

```ts
const pages = [];
for (let i = 0; i < doc.pageCount; i++) pages.push(await doc.text.extract(i));
```

Part of [TextApi](https://kernstra.com/docs/web-sdk/api/doc-text) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/doc-text/extract
