wonday / react-native-pdf

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

Unable to open specific password protected file #860

Open mastercodebegin opened 3 months ago

mastercodebegin commented 3 months ago

What react-native version are you using? react-native": "0.70.6

What react-native-pdf version are you using? "react-native-pdf": "^6.7.5"

What platform does your issue occur on? (android/ios/both) Android(didn't test on iOS) Describe your issue as precisely as possible : i'm trying to open password protected bank statement and it's giving me an error although i'm entering valid password but there is a issue with only icici bank credit card statement password i'm able to open other banks statement they are also password protected and they are being opened properly. i tried icici statement with other app they are opening please check and let me know. statement link - https://drive.google.com/file/d/1dE_AieY-vYhFHcWx50HWJG-H0x0XIbOT/view?usp=sharing password is - firo1206

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

Screenshot 2024-08-19 at 7 37 22 PM

Show us the code you are using?

 {!visible ?
          <Pdf
            onScaleChanged={(v) => console.log('changed================================', v)
            }
            trustAllCerts={false}
            password={text}
            onPressLink={(uri) => {
              console.log(`Link pressed: ${uri}`);
            }}
            source={{ uri: props.route.params.uri }}
            onError={(error) => {

              PdfPasswordErrorHandler(error)
            }}
            onPageChanged={(page, numberOfPages) => {
              setTotalPage(numberOfPages)
              setCurrentPage(page)
              console.log(`Current page: ${page}${numberOfPages}`);
            }}
            style={styles.pdf} />

          :
          <ModalView
            visible={visible}
            errorRecognize={text}
            errorMessage={errorMsg}
            onText={onChangeText}
            num={num}
            onPressOkay={onPressOkayHandler}
            onPressClose={onPressCloseHandler}
            close={'CLOSE'}
            open={'OPEN'} />
        }
martintan commented 2 months ago

Hey, I was able to try recreating your issue on both iOS and Android, using the example project. However, on both platforms, it is working fine for me.

iOS Android
image image

how I downloaded and passed the password of your PDF file:

let source = require('./4315XXXXXXXX7005_739857_Retail_Amazon_NORM.pdf');
// ...

                    <Pdf ref={(pdf) => {
                        this.pdf = pdf;
                    }}
                         source={source}
                         password="firo1206"
                         scale={this.state.scale}
                         horizontal={this.state.horizontal}

I must note that in order to run this project using latest XCode (15) and Android Studio (Koala), I had to make multiple changes to build configurations, especially on the android project. I tried your issue on both react native 0.69.12 and 0.70.6, it works on both.

I'm guessing your password may have been passed incorrectly (maybe there were spaces?) or something else in your code went wrong. I'd need more information like environment or source code in order to debug and recreate the issue

here's my environment(s):

Environment

iOS

Android

mastercodebegin commented 2 months ago

Thanks martin i will try again. i will get back to you if you have time so can we connect if needed.