小工具知识网

当前位置: 首页 > 行业知识 > 如何在前端展示后端返回的pdf Base64格式字符串

行业知识

如何在前端展示后端返回的pdf Base64格式字符串

2026-11-15 21:45:57 来源:互联网转载

文章目录

  • 如何在前端展示后端返回的pdf Base64格式字符串

    如何在前端展示后端返回的pdf Base64格式字符串

    // fileBase64 就是后端返回的 pdf Base64格式字符串    getPdfDocument(fileBase64) {          let fileBlob = this.base64ToBlobsdf(fileBase64,'application/pdf');          let basePdfUrl = window.URL.createObjectURL(fileBlob);          sessionStorage.setItem('basePdfUrl', basePdfUrl);          location.href = "lookPdf.html";          let newWindow = window.open("");          newWindow.document.write("");        }      })    },    base64ToBlobsdf(fileBase64,fileType){      let raw = window.atob(fileBase64);      let rawLength = raw.length;      let uint8Array = new Uint8Array(rawLength);      while (rawLength--){        uint8Array[rawLength] = raw.charCodeAt(rawLength);      }      return new Blob([uint8Array],{type: fileType});    },

上一篇:揭秘可可网络验证源码,深度解析与探究神秘面纱

下一篇:服务器上怎么打包源代码?