【问题标题】:Base64 encoded to pdf in Google chrome?Base64 在 Google chrome 中编码为 pdf?
【发布时间】:2018-03-19 10:51:52
【问题描述】:

我们如何在 Google chrome 中使用来自 base64 的 JavaScript 显示 PDF? 作为应用程序:PDF,base64:pdfbase64binary 不再工作

【问题讨论】:

    标签: javascript google-chrome pdf base64


    【解决方案1】:
    window.open("data:application/octet-stream;base64," + response)
    

    【讨论】:

      【解决方案2】:

      您可以使用Blob URL 来表示文件。

      fetch(<data URI>)
      .then(response => response.blob())
      .then(blob => {
        // do stuff with `Blob URL`
        const blobURL = URL.createObjectURL(blob);
      });
      

      另见Creating a Blob from a base64 string in JavaScript Base64 PDF in new tab shows Blank Page before Refresh.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-18
        • 2012-11-12
        • 2014-04-18
        • 2012-07-17
        相关资源
        最近更新 更多