wonday / react-native-pdf

A <Pdf /> component for react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

sobrinho opened this issue · comments

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;

Facing Same issue

Is resolved?

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

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

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 ( <View style={styles.safeArea}> <Pdf source={source} trustAllCerts={false} style={{flex: 1}} /> </View> )
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.

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.

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