wonday / react-native-pdf

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

Loading indicator stays during loading always at 0.00% and sometimes goes into -839393.0% #876

Open alexandravychytill opened 1 week ago

alexandravychytill commented 1 week ago

What react-native version are you using? 0.74.0

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 :

The pdf is loading eventually, but the indicator always stays at 0.00% during the loading time. Also when a pdf gets opened via deep link then the indicator shows the percentage in minus, for example -839393.0%. When I tried to implement my own activityIndicator the progress was also always 0. And when trying to use onLoadProgress, this does not even get executed.

Show us the code you are using?

<Pdf trustAllCerts={Platform.OS === 'ios'} style={styles.viewer} source={{ uri: ${currentUrl}, headers: { Cookie: ;${authCookie} }, }} />

rajivchaulagain commented 2 days ago
 <Pdf
          ref={pdfRef}
          trustAllCerts={false}
          source={{
            uri,
          }}
          onLoadProgress={(percent) => calculateLoadingProgress(percent)}
          style={{
            width,
            height,
          }}
          onPageSingleTap={(e, x, y) => handlePosition(e, x, y)}
          onLoadComplete={(numberOfPages, path, { height, width }) =>
            console.log(`height & width : ${height} ${width}`)
          }
        />

and  
 const calculateLoadingProgress = (percent) => {
    if (percent === 1) {
      setPdfLoading(true);
    }
  };

I used this way for managing loading it shows loading from 0 to 1 for complete

LorandP commented 2 days ago

@rajivchaulagain This worked for me! Thanks

rajivchaulagain commented 1 day ago

@LorandP no worries I'm glad that it worked.

RJS32 commented 1 hour ago

to fix your trouble check this solution click maybe this will solve your problem.