0

When using react-native-pdf and the example uri provided it does not appear in my app. A loading bar is only displayed. Does anyone know what may be causing this issue?

Loading bar displayed underneath messages:

enter image description here

Code below:

  return <SafeAreaView style={{ flex: 1}}>{chat}
     
          <View style={styles.container}>
                      <Pdf
     source={{uri:'https://samples.leanpub.com/thereactnativebook-sample.pdf',cache:true}}
                         onLoadComplete={(numberOfPages,filePath)=>{
                             console.log(`number of pages: ${numberOfPages}`);
                         }}
                         onPageChanged={(page,numberOfPages)=>{
                             console.log(`current page: ${page}`);
                         }}
                         onError={(error)=>{
                             console.log(error);
                         }}
                         onPressLink={(uri)=>{
                             console.log(`Link presse: ${uri}`)
                         }}
                         style={styles.pdf}/>
           </View>
        </SafeAreaView>;
      }
   }

   const styles = StyleSheet.create({
    container: {
      flex: 1,
      justifyContent: 'flex-start',
      alignItems: 'center',
      marginTop: 25,
    },
    pdf: {
      flex:1,
      width:Dimensions.get('window').width,
      height:Dimensions.get('window').height,
    }
 });
AJDee
  • 147
  • 1
  • 14
  • are you using react-native-pdf package..? make sure you installed all the dependency for that package – Rahman Haroon Sep 27 '21 at 08:01
  • Yes, I did the following: npm install react-native-pdf rn-fetch-blob @react-native-community/progress-bar-android @react-native-community/progress-view --save – AJDee Sep 27 '21 at 11:49
  • if you are using react native cli you need to link the package..did u done that too? – Rahman Haroon Sep 27 '21 at 13:21

0 Answers0