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

# my.openDocument

> Open and preview a document file.

Preview a PDF file within the Mini Program, without leaving the Mini Program.

## Parameters

| Property | Type     | Required | Description                                  |
| -------- | -------- | -------- | -------------------------------------------- |
| filePath | String   | Yes      | File path, obtained via `my.downloadFile`    |
| fileType | String   | Yes      | File type. Only `pdf` is currently supported |
| success  | Function | No       | Callback on success                          |
| fail     | Function | No       | Callback on failure                          |
| complete | Function | No       | Callback that always executes                |

## Error Codes

| Code | Description                                                   | Solution                                           |
| ---- | ------------------------------------------------------------- | -------------------------------------------------- |
| 4011 | File path is invalid or no permission to access incoming path | Check the incoming file path                       |
| 4012 | Preview files do not exist                                    | Make sure files that correspond to file path exist |
| 4013 | File format is not supported                                  | Currently preview of PDF files is supported        |

## Code Example

```javascript theme={null}
my.openDocument({
  filePath: documentPath,
  fileType: 'pdf',
  success: () => {
    console.log('Document opened');
  }
});
```
