How to add or open a pdf in my react native expo app

Hi there I m trying to create book app with expo where a user can click on book cover image and then pdf should open. Pdf is in url form Please Help
This Post was posted on 10-03-2021

Yeah everybody! If you are having the same problem here is the answer for that. Because I was struggling to find a answer for How to open a pdf in react native expo app So Yeah I tried this idea with this help of Mr. Perez He guided me very well on discord. Thanks to him I dont know if it works in the time when you are seeing this post but it is working on 11-03-2021 So What you have to do.
First download these library by yarn or npm

Requirements

  • :point_right: Install react-native-webview on your own!
  • :point_right: Install expo-file-system on your own!
  • :point_right: Install expo-constants on your own!

So these libraries should be installed prior to this one
After you have installed these libraries you have to install
rn-pdf-reader-js Then this is it

import React from ‘react’
import { ScrollView, View, } from ‘react-native’
import PDFReader from ‘rn-pdf-reader-js’

export default class Publications extends React.Component {
render() {
return (
<PDFReader
source={{
uri: ‘http://www.africau.edu/images/default/sample.pdf’,
}}
/>
)
}
}
So this is it If this didn’t worked for you Just make sure to repeat all those steps and if it didn’t worked even after repeating then you will have to find another answer. I m posting this on 12-03-2021

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.