# PDFDocument.fromBytes()

```ts
static fromBytes(bytes: Uint8Array, options?: OpenOptions): Promise<PDFDocument>
```

Load a PDF from a `Uint8Array`.

- Kind: static method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `bytes` | `Uint8Array` | The PDF bytes. |
| `options?` | `OpenOptions` | `{ password? }` — the password of an encrypted file. |

Returns `Promise<PDFDocument>`

Throws:

- `NOT_INITIALIZED` — `Kernstra.init()` has not resolved.
- `FORMAT_ERROR` — not a PDF, or a corrupt one.
- `PASSWORD_ERROR` — a password is required, or the one supplied is wrong.
- `SECURITY_ERROR` — encrypted with a security handler the SDK cannot open.
- `LICENSE_REQUIRED` — opened under a stopped license: no document opens.
- `OUT_OF_MEMORY` — the SDK could not allocate the memory the file needs.
- `ENGINE_FAILED` — the SDK stopped on an unrecoverable fault (fatal).

```ts
const bytes = new Uint8Array(await (await fetch('/terms.pdf')).arrayBuffer());
const doc = await PDFDocument.fromBytes(bytes);
```

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

Web page: https://kernstra.com/docs/web-sdk/api/pdfdocument/frombytes
