File
my.openDocument
Open and preview a document file.
Preview a PDF file within the Mini Program, without leaving the Mini Program.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Open and preview a document file.
| 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 |
| 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 |
my.openDocument({
filePath: documentPath,
fileType: 'pdf',
success: () => {
console.log('Document opened');
}
});