小编Luc*_*ndz的帖子

如何打开本地pdf IOS React Native

我想打开一个以前下载并存储在手机中的pdf文件。

本地 url 文件:file:///var/mobile/Containers/Data/Application/ ... 更多 url ... /example.pdf

我正在使用 Expo 库在 Android 中打开:

if (Platform.OS !== 'ios') {
    FileSystem.getContentUriAsync(pdfLocalUrl).then((cUri) => {
      IntentLauncher.startActivityAsync('android.intent.action.VIEW', {
        data: cUri.uri,
        flags: 1,
        type: 'application/pdf',
      });
    });
  }
Run Code Online (Sandbox Code Playgroud)

我没有找到在 ios 中打开的方法。找不到 webView 和 linking.OpenUrl,因为需要一个有效的 web url。

Linking.openURL(pdfLocalUrl);
Run Code Online (Sandbox Code Playgroud)

带有 gdoc 的 webView 也不起作用:

renderPdfOffline = () => {
const html = 'https://drive.google.com/viewerng/viewer?embedded=true&url=';
return (
  <WebView
    style={{ flex: 1 }}
    scalesPageToFit={true}
    source={{
      uri: html + this.state.pdfUrl,
    }}
  ></WebView>
);
Run Code Online (Sandbox Code Playgroud)

};

pdf offline native local reactjs

5
推荐指数
0
解决办法
552
查看次数

标签 统计

local ×1

native ×1

offline ×1

pdf ×1

reactjs ×1