i'm using react-native-document-picker to select a PDF. After the selection i'm passing the URI of the file to PDF of react-native-pdf. It returns me this error, but only on iOS. In Android works fine. Any suggestions?
ON ERROR --- Error: Load pdf failed. path=file:///private/var/mobile/Containers/Data/Application/250D8D83-5F0F-402C-912B-F1B199551218/tmp/com.yada.nen-Inbox/Bolletta%20Luce%20a2a.pdf
at createErrorFromErrorData (NativeModules.js:152)
at NativeModules.js:104
at MessageQueue.__invokeCallback (MessageQueue.js:442)
at MessageQueue.js:127
at MessageQueue.__guard (MessageQueue.js:343)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
at debuggerWorker.js:80
And this is how i'm picking the PDF:
static pickPDF = async (callBack,goBack=()=>{}) => {
try {
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.pdf],
});
console.log("URI of the uploaded PDF: ", res.uri);
callBack(res.uri, res.name);
} catch (err) {
if (DocumentPicker.isCancel(err) ) {
goBack();
} else {
throw err;
}
}
};
And below is how i'm showing the PDF with react-native-pdf:
<Pdf
source={{uri:"file://"+this.state.pdfUri, cache: false}}
horizontal
page={page}
scrollEnabled={false}
onError={(error)=>{
console.log("ON ERROR ---",error);
}}
onPageChanged={this.onPageChanged}
style={flex}
/>