wonday / react-native-pdf

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

Pdf not loading first time in Android ,gives error open failed:ENONT #837

Open Abhishektaurus opened 6 months ago

Abhishektaurus commented 6 months ago

What react-native version are you using? 0.73.5

What react-native-pdf version are you using? 6.7.1

What platform does your issue occur on? (android/ios/both) Android

Describe your issue as precisely as possible : 1) Steps to reproduce the issue or to explain in which case you get the issue

This issue is coming on Android device only for the first time, whenever I open the PDF file page, it shows loading continuously and after going back and forth, it shows the pdf. This issue is coming for fresh users for the first time and I have shared the logs which I got if I stay on the loading page only.

2) Interesting logs No such file '/data/user/0/com.example.app/files/doc.pdf'; /data/user/0/com.example.app/files/doc.pdf: open failed: ENOENT (No such file or directory) "https%3A%2F%2Fcustom.cvent.com/ECAEE9AB812E47DC813BADF3B284DF14/files/e0237949440a4d0c9a4dc1184591dcb8.pdf"

Can you please help me in this as I am stuck in this issue ? Don't know how to proceed. Thanks in advance!!

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

Show us the code you are using?

tuanlevi95 commented 5 months ago

same issue

coyksdev commented 5 months ago

same issue

GilTRipper commented 5 months ago

+1

Tamiyadd commented 5 months ago

for me, adding trustAllCerts={false} prop solved the issue

Abhishektaurus commented 5 months ago

I am already using this prop but still facing this issue and I think there is an issue in caching in the library maybe for that reason, it is failing at first time only. @wonday can you please help?

kr396 commented 5 months ago

for me, adding trustAllCerts={false} prop solved the issue

Worked for me

Abhishektaurus commented 5 months ago

<View accessibilityLabel={t('Attachments-Pdf-Accessibility')} style={{ flex: 1 }}

<Pdf source={source} trustAllCerts={false} onError={onError} renderActivityIndicator={() => (

)} onLoadComplete={onLoadComplete} onPressLink={async uri => { LOG.debug(Attempting to handle opening link "${uri}"); try { if (uri.startsWith('mailto:') || uri.startsWith('tel:')) { if (await Linking.canOpenURL(uri)) { Linking.openURL(uri); } else { LOG.error( Device does not have an app installed to support ${uri} ); } } else { openExternalWebview(uri); } } catch (error) { LOG.error(Error handling pressing link ${uri}. ${error.message}); } }} style={{ flex: 1, width: '100%', height: '100%' }} /> ); };

I am passing trustAllCerts={false} already, but the clients are facing the issue of PDF not loading first time intermittently...

@wonday @coyksdev @Tamiyadd

NewDawnFades21 commented 5 months ago

for me, adding trustAllCerts={false} prop solved the issue

you saved my life