Please provide the following:
SDK Version: 45.0.6
Add the appropriate “Tag” based on what Expo library you have a question on.
I have a PDF in my
I import that pdf with
const PDF = require("/path/to/pdf")
I then try to render it in a WebView like so:
The app displays the following content:
I suspect you’re running into the issues mentioned here:
This file has been truncated.
# React Native WebView Guide
This document walks you through the most common use cases for React Native WebView. It doesn't cover [the full API](Reference.md), but after reading it and looking at the sample code snippets you should have a good sense for how the WebView works and common patterns for using the WebView.
_This guide is currently a work in progress._
## Guide Index
- [Basic Inline HTML](Guide.md#basic-inline-html)
- [Basic URL Source](Guide.md#basic-url-source)
- [Loading local HTML files](Guide.md#loading-local-html-files)
- [Controlling navigation state changes](Guide.md#controlling-navigation-state-changes)
- [Add support for File Upload](Guide.md#add-support-for-file-upload)
- [Multiple files upload](Guide.md#multiple-files-upload)
- [Add support for File Download](Guide.md#add-support-for-file-download)
- [Communicating between JS and Native](Guide.md#communicating-between-js-and-native)
- [Working with custom headers, sessions, and cookies](Guide.md#working-with-custom-headers-sessions-and-cookies)
### Basic inline HTML
I think the problem is that there’s no way to specify the Content-Type for the content.
Thank you – perhaps this is indeed the issue. However, for some reason, when I load an external PDF file (one hosted on a remote server) it works. It’s just the local files that don’t work.
Do you have a solution that I could use, or any suggestions for things to try?
Yes, the problem is specifically with loading local files.
If you are hosting the PDF on a remote server, the server will return the Content-Type in the HTTP headers.
One thing you could try is include a simple web server within your app. I have not tried this myself:
Install it with
yarn. Skip the
react-native link step. Make sure you build with
EAS Build and run a custom dev client instead of Expo Go.
I think you could use
expo-file-system instead of