//content是base64格式
viewPdf(content) {
console.log("content",content)
const blob = this.base64ToBlob(content)
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob)
} else {
const fileURL = URL.createObjectURL(blob)
window.open(fileURL);//彈出ppf文件
}
},
base64ToBlob(code) {
code = code.replace(/[\n\r]/g, '')
// atob() 方法用于解碼使用 base-64 編碼的字符串踪宠。
const raw = window.atob(code)
const rawLength = raw.length
const uInt8Array = new Uint8Array(rawLength)
for (let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i)
}
return new Blob([uInt8Array], { type: 'application/pdf' })
},