react-native-pdf icon indicating copy to clipboard operation
react-native-pdf copied to clipboard

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

Open Abhishektaurus opened this issue 1 year ago • 9 comments

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.

  1. 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?

Abhishektaurus avatar May 21 '24 13:05 Abhishektaurus

same issue

tuanlevi95 avatar May 27 '24 03:05 tuanlevi95

same issue

coyksdev avatar May 27 '24 09:05 coyksdev

+1

GilTRipper avatar May 27 '24 09:05 GilTRipper

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

Tamiyadd avatar May 27 '24 10:05 Tamiyadd

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?

Abhishektaurus avatar May 27 '24 12:05 Abhishektaurus

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

Worked for me

kr396 avatar May 31 '24 07:05 kr396

<View accessibilityLabel={t('Attachments-Pdf-Accessibility')} style={{ flex: 1 }} > <Pdf source={source} trustAllCerts={false} onError={onError} renderActivityIndicator={() => ( <LoadingState backgroundColor={theme.colors.base} /> )} 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%' }} /> </View> ); };

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

@wonday @coyksdev @Tamiyadd

Abhishektaurus avatar Jun 01 '24 18:06 Abhishektaurus

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

you saved my life

NewDawnFades21 avatar Jun 18 '24 07:06 NewDawnFades21

pour moi, l'ajout trustAllCerts={false}d'un accessoire a résolu le problème

Thank

Ange0 avatar May 22 '25 15:05 Ange0