Document Viewer
The viewer module is designed to work with the files that the document picker module returns. It supports both uri and bookmark coming from open and import modes, also supports virtual files and long-term access to the files.
The call to viewDocument returns a promise that resolves with null in case of success or rejects with error.
How it works
- Android
- iOS
viewDocument uses Intent.ACTION_VIEW internally.
viewDocument uses the QuickLook framework internally.
View a document given a uri
Uri would come from the open or import modes of the document picker.
See more in the API reference
Previewing a document given a uri
import { viewDocument } from '@react-native-documents/viewer'
return (
<Button
title="view the last imported file"
onPress={() => {
const uriToOpen = 'file:///path/to/your/file'
viewDocument({ uri: uriToOpen, mimeType: 'some-mime' }).catch(handleError)
}}
/>
)
View a document given a bookmark
bookmark would come from the open mode, with the requestLongTermAccess option set to true.
See more in the API reference
Previewing a document given a bookmark
import { viewDocument } from '@react-native-documents/viewer'
return (
<Button
title="view the last imported file"
onPress={() => {
const bookmark = '...'
viewDocument({ bookmark }).catch(handleError)
}}
/>
)