【问题标题】:Downloadinf PDF from React native webview gives "invaild pdf format or corrupted" after opening on Android but works fine on iOS从 React 本机 webview 下载 PDF 在 Android 上打开后会出现“无效的 pdf 格式或损坏”,但在 iOS 上可以正常工作
【发布时间】:2021-11-04 02:57:49
【问题描述】:

我正在使用以下代码打开一个 URL。在 Android 上打开后从 React 本机 webview 下载 PDF 给出:

“pdf格式无效或损坏”

但它在 iOS 上运行良好。

<WebView
        renderToHardwareTextureAndroid={true}
        startInLoadingState={isLoading}
        renderLoading={() => {
          return <BarIndicator color="blue" />;
        }}
        mediaPlaybackRequiresUserAction={false}
        javaScriptEnabled={true}
        source={{
          uri: webviewUrl,
          headers: webviewHeaders,
        }}
        style={drawerWebviewStyles.container}
      />

【问题讨论】:

    标签: react-native pdf react-native-android react-native-webview


    【解决方案1】:

    pdf 在 android webview 上不起作用检查这个问题here 你可以寻找其他解决方案,例如下载它并使用 pdf 查看器打开它

    【讨论】:

      【解决方案2】:

      似乎是一个众所周知的 5 年前的问题

      https://react-native.canny.io/feature-requests/p/android---webview-cannot-display-pdf

      需要 saveas file.pdf 然后要么调用本机 pdf 处理程序

      或

      嵌入/自定义一个简单维护的 js 查看器,例如

      https://github.com/xcarpentier/rn-pdf-reader-js

      【讨论】:

        猜你喜欢
        • 2012-10-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-16
        • 1970-01-01
        • 1970-01-01
        • 2023-03-16
        • 2022-12-30
        相关资源
        最近更新 更多