# PagesApi.extract()

```ts
extract(indices: number[]): Promise<Uint8Array>
```

Builds a **new** PDF from those pages, in that order. The source is untouched. A page with form fields comes out flattened, as it prints: its fields do not go to another document. The new document gets a creation date. Needs the `export` feature.

- Kind: method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `indices` | `number[]` | Zero-based page indices, in the order they should appear. |

Returns `Promise<Uint8Array>`: The new PDF's bytes.

Throws:

- `INVALID_ARGUMENT` — no pages, or a page the document lacks.
- `PAGE_ERROR` — the pages could not be copied.
- `EXPORT_FAILED` — a page with form fields could not be flattened, or the new document could not be watermarked or serialized.
- `FEATURE_NOT_LICENSED` — the license lacks `export`.
- `DOCUMENT_CLOSED` — the document has been closed.
- `INVALID_STATE` — a progressive document still downloading.

```ts
const firstTwo = await doc.pages.extract([0, 1]);
```

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

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