This allows you to render documents like PDF, DOC, XLS and PPT.
expo install react-native-document react-native-webview
npm install react-native-document react-native-webview
# OR
yarn add react-native-document react-native-webview
# OR
pnpm add react-native-document react-native-webview
# OR
bun add react-native-document react-native-webview
import DocumentView from 'react-native-document';
export default function App() {
return (
<DocumentView uri="https://..." />
)
}
uri
The URI of the file to be rendered.
➤ Type: string
scale
An optional scale value or object that determines the initial, minimum, and maximum scale of the document. If a number is provided, it sets for all properties. If an object is provided, it can have optional properties initial
, min
, and max
to set the initial, minimum, and maximum scale, respectively.
➤ Type: number
| { initial?: number; min?: number; max?: number }
controls
An optional boolean value or object that determines whether controls are displayed and which controls are displayed. If a boolean value is provided, it determines whether all controls are displayed. If an object is provided, it can have optional properties page
and zoom
to determine whether page and zoom controls are displayed, respectively.
➤ Type: boolean
| { page?: boolean; zoom?: boolean }
style
An optional StyleProp object that can be used to apply custom styles to the component.
➤ Type: StyleProp<ViewStyle>
renderLoading
Function that returns a loading indicator.
➤ Type: () => React.ReactElement
onLoad
➤ Type: (event: DocumentViewEvent) => void
onError
An optional callback function that is called when the document cannot be loaded. It receives an event object of type DocumentViewEvent
.
➤ Type: (event: DocumentViewEvent) => void