> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supernote.com/llms.txt
> Use this file to discover all available pages before exploring further.

# openFile

> Open the specified document or note file.

<Note>
  Currently supported file formats are: `pdf`, `epub`, `cbz`, `xps`, `fb2`, and `note`.
</Note>

```ts theme={null}
static openFile(filePath: string, page: number): Promise<APIResponse<boolean>>;
```

**Parameters**

| Parameter  | Type     | Description                                                                                                       |
| ---------- | -------- | ----------------------------------------------------------------------------------------------------------------- |
| `filePath` | `string` | File path to open                                                                                                 |
| `page`     | `number` | Page index. `0` or greater jumps to the specified page, and `-1` keeps the last viewed page when opening the file |

**Returns**

* [`APIResponse<boolean>`](/en/api-reference/supernote-plugin/types/api-response):
  `result === true` indicates the file was opened successfully

**Throws**

* Throws a parameter validation error when `filePath` is not a non-empty string
* Throws a parameter validation error when `page` is not an integer greater than or equal to `-1`

## Example

```ts wrap theme={null}
import { PluginFileAPI } from 'sn-plugin-lib';

/**
 * Example: open a file.
 */
export async function exampleOpenFile() {
  const page = -1;
  const res = await PluginFileAPI.openFile('/storage/emulated/0/Document/demo.pdf', page);
  if (!res.success) {
    console.log('openFile failed', res.error);
    throw new Error(res.error?.message ?? 'openFile call failed');
  }
  console.log('openFile result', res.result);
  return res.result;
}
```
