如何在浏览器中使用BASE64键打开PDF

问题描述 投票:-1回答:1

我已经看到了许多使用base64打开PDF的参考。什么都没有为我工作。

我尝试使用window.open('data:application/pdf;base64,' + base64data);,但它只是在浏览器中显示空白页。

如果将base64data保留在iFrame标记中,则可以查看pdf。根据我的要求,我需要在新标签页中打开此PDF。

请帮助我解决此问题。

javascript html jquery sapui5
1个回答
0
投票

尝试此代码

let pdfWindow = window.open("")
pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encodeURI(base64data) + "'></iframe>")
© www.soinside.com 2019 - 2024. All rights reserved.