I'm trying to display a downloaded pdf inside a WebView. I'm using react-native-webview
(https://github.com/react-native-community/react-native-webview) and rn-fetch-blob
to download it.
Basically i have a render that's just a WebView component:
if(this.state.path)
return
<WebView
source={{ uri: this.state.path }}
style={{ flex: 1 }}
/>
else return <Loader />
This component won't get rendered until the PDF is downloaded. After the download is complete i save the path into the state and show the WebView.
The PDF is downloaded correctly, i can manually go to the path i get in the state and open the PDF.
If i put the URL where i download the pdf from inside the uri like this (as example this is the google policy):
source = {{ uri : "https://static.googleusercontent.com/media/www.google.com/it//intl/it/policies/privacy/google_privacy_policy_it.pdf" }}
It works correctly and displays the pdf inside the WebView
.
If i put my path to the pdf doing :
source = {{ uri : path/to/file.pdf}}
I get a blank screen.
Is there a way to display a file system pdf into the WebView
?
Note that i need to use the WebView
, react-native-pdf
and react-native-pdf-view
are not the solution