如何在前端展示后端返回的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("<iframe width='100%' height='100%' src='"+basePdfUrl+"'></iframe>");
}
})
},
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});
},