Using react native I am trying to download a PDF file (Sample PDF File). After download completes, it should open with 3rd party pdf viewer
Please guide me how to do this in react native.
React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces. Use a little—or a lot. You can use React Native today in your existing Android and iOS projects or you can create a whole new app from scratch.
React Native supports building apps for iOS, Android, and web from a single code base. It's a more affordable technology than Swift, yet it allows creating high-quality apps.
1) Download base64 encoded pdf file.
2) Decode base64 encoded file ( I suggest you use react-native filehandler)
3)In order to view pdf you can use webview on IOS
<WebView style={{
flex: 1
}} scalesPageToFit={true} source={{
uri: --base64EncodedContent--
}}
>
</WebView>
for android you can use react-native pdf view https://github.com/cnjon/react-native-pdf-view
<PDFView
path={this.props.src} //path of pdf file you saved
pageNumber={1}
onLoadComplete = {(pageCount) => {
}}
style={styles.pdf}>
</PDFView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With