Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

Display a PDF in react-native-webview after fetch. iOS only

$
0
0

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


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>