wonday / react-native-pdf

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

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

Open kuldip-trentium opened 1 month ago

kuldip-trentium commented 1 month 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 1 month 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 1 month 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