wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.6k stars 553 forks source link

for expo 51 react-native-pdf is not working #856

Open kuldip-trentium opened 3 months ago

kuldip-trentium commented 3 months ago

What react-native version are you using? 0.74.3 What react-native-pdf version are you using? 6.7.5 What platform does your issue occur on? (android/ios/both) both Describe your issue as precisely as possible : 1) Steps to reproduce the issue or to explain in which case you get the issue 2) Interesting logs

Join a screenshot or video of the problem on the simulator or device?

Show us the code you are using? <Pdf source={{ uri: 'https://morth.nic.in/sites/default/files/dd12-13_0.pdf', cache: true, }} trustAllCerts={false} style={{ flex: 1, width: "100%", }} onError={(error) => { console.error(error, "error"); }} />

ngima commented 3 months ago

@kuldip-trentium Are you using dev-client build or expo go? What error/error logs are you getting?

I just tried it in v6.7.5 with expo 51 dev-client build with iOS and it's working for me

  <Pdf
    source={{ uri: 'http://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 pressed: ${uri}`);
    }}
    style={{
        flex: 1
    }} />

image

ngima commented 3 months ago

I indeed had issue with Android that it was stuck on loading screen because of

[Error: ReactNativeBlobUtil request error: java.lang.IllegalStateException: Use of own trust manager but none definedjava.lang.IllegalStateException: Use of own trust manager but none defined]

Which is fixed with

<Pdf
  source={source}
  trustAllCerts={false}
  ....
  >

as mentioned in https://github.com/wonday/react-native-pdf/issues/568#issuecomment-1929108820 comment from @ruipaulo