wonday / react-native-pdf

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

Android: Does not work with any remote URL - Possible unhandled promise rejection (id: 2): Error: /data/user/... open failed: ENOENT (No such file or directory) #844

Open sobrinho opened 3 weeks ago

sobrinho commented 3 weeks ago

What react-native version are you using? 0.74.1

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

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 2) Interesting logs Got this exception no matter what URL is provided either cache enabled or disabled.

Works fine with Blob but not with remote URLs.

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

Screenshot 2024-06-12 at 11 29 38

Show us the code you are using?

import Pdf from "react-native-pdf";
import { StyleSheet, Dimensions, Text, View } from "react-native";
import { useState } from "react";

const MyWebComponent = () => {
  const [source, setSource] = useState(null);

  const uri = "https://www.clickdimensions.com/links/TestPDFfile.pdf";

  return (
    <View style={styles.container}>
      <Pdf source={{ uri: uri, cache: true }} style={styles.pdf} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'flex-start',
    alignItems: 'center',
    marginTop: 25,
  },

  pdf: {
    flex:1,
    width:Dimensions.get('window').width,
    height:Dimensions.get('window').height,
  }
});

export default MyWebComponent;
amjpdevp commented 3 weeks ago

Facing Same issue

sobrinho commented 2 weeks ago

@wonday hints?

1141389882 commented 2 weeks ago

Is resolved?

Marcin-Falkowski commented 2 weeks ago

trustAllCerts={false} helps but in my opinion it isn't good resolve for our problem.

sobrinho commented 2 weeks ago

There's no issue with the certs on the URLs I'm trying. How this would help?

Marcin-Falkowski commented 2 weeks ago

I'm not 100% sure how this would help because i found this resolve in closed issues. I use amazon url's so i can imagine that the certs aren't 100% correct because i had a problem with that before and it works for me now.

But your link is working for me too with this parameter setted on false. ` const source = { uri: 'https://www.clickdimensions.com/links/TestPDFfile.pdf', cache: true, } return (

)`

image

Only difference between our environments is React Native version because i use 0.73.3 so if it still doesn't work, you have to wait for other answers, maybe it is something with new architecture.

sobrinho commented 2 weeks ago

Interesting, I will give it a try, maybe the prop name is misleading to what it's actually doing.

I tried a bunch of different URLs and I'm certain the certs are okay since they work everywhere but this library.

Abhishektaurus commented 2 weeks ago

I am also facing the same issue in my app as well. Even it is not working after using trustAllCerts={false} . React Native Version : 0.73.5 Android Version: 12,13

Many clients are impacted due to this in my app. can you please help ??

Jackmekiss commented 1 week ago

I resolved it with the props trustAllCerts={false}.

Not sure why.