# PDFDocument.fromFile()

```ts
static fromFile(file: File, options?: OpenOptions): Promise<PDFDocument>
```

Load a PDF from a `File` object (file picker).

- Kind: static method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `file` | `File` | A `File`, from a file picker or a drop. |
| `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
input.addEventListener('change', async () => {
  const [file] = input.files ?? [];
  if (file) doc = await PDFDocument.fromFile(file);
});
```

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/fromfile
