React Native WebView for Android 不显示 PDF 和 Word 文件 [英] React Native WebView for Android not displaying PDF and Word files

查看:92
本文介绍了React Native WebView for Android 不显示 PDF 和 Word 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个关于发布个人简历的新项目.

I am developing a new project about publishing Personal CV.

我需要在应用程序中显示用户的简历.

I need to show users' CVs in the application.

我的标准 WebView 代码如下并且在 iOS 上运行良好.

My standard WebView code is below and working well on iOS.

import * as React from 'react';
import { WebView } from 'react-native';


export default class App extends React.Component {
  render() {
    return (
      <WebView
            style={{flex: 1, backgroundColor: 'white'}}
            source={{
              uri: 'http://www.africau.edu/images/default/sample.pdf',
            }}
            bounces={true}
            useWebKit={true}
            scrollEnabled={true}
          />
    );
  }
}

此代码也需要在 Android 上运行.当我在 Android 上尝试时,页面什么也没显示.

This code also needs to work on Android. When I try it on Android the page shows nothing.

你可以在 Expo Snack 上试试这个.

推荐答案

Android Webview 无法显示 PDF 文件.有一个与此问题相关的问题.你可以从这个链接

Android Webview cannot display PDF files. There is an issue related to this problem. You can view it from this link

您的问题有多种解决方案,您可以为自己选择最相关的一种.

There are multiple solutions to your problem, you can pick the most relevant one for yourself.

1) 使用 react-native-pdf-view

2) 使用 Google 文档作为查看器.尝试在您的 Web 视图中加载此 URL http://docs.google.com/gview?embedded=true&url=http://www.africau.edu/images/default/sample.pdf

2) Use Google Docs as a viewer. Try to load this URL in your Webview http://docs.google.com/gview?embedded=true&url=http://www.africau.edu/images/default/sample.pdf

3) 使用 Chrome 自定义标签.

这篇关于React Native WebView for Android 不显示 PDF 和 Word 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆