无法显示Base64 PDF数据IE和Edge [英] Base64 PDF data IE and Edge does not show up
本文介绍了无法显示Base64 PDF数据IE和Edge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个PDF,其内容被加密为base64字符串.我试图将其显示在 embed
元素中.它在Chrome以及Microsoft Edge和Internet Explorer以外的其他浏览器中都可以正常工作.
I have a PDF whose content is encrypted as a base64 string. I am trying to display it in an embed
element. It works fine in Chrome and other browsers except Microsoft Edge and Internet Explorer.
success: function (data, textStatus, xhr) {
$("#url").html("");
$("#url").append("<embed src=\"" + data.encodeUrl + "\" class=\"iframe\"></embed>");
$("#cameraLink").modal('show');
}
推荐答案
这对我有用:
.then(
pdf=> {
let content = `data:application/pdf;base64, ${encodeURIComponent(pdf)}`;
let pdfSrc = content;
let html = `<object data="${pdfSrc}" type="application/pdf" width="100%" height="100%">
<iframe width="100%" height="100%" src="${pdfSrc}">
</iframe>
</object>`;
let newPdfWindow = window.open("new window");
newPdfWindow.document.write(html);
this.loadingCF.next(false);
});
使用包裹在< object>
标记内的< iframe>
,该标记在新窗口中打开.
Using <iframe>
wrapped inside the <object>
tag, which i open in a new window.
这篇关于无法显示Base64 PDF数据IE和Edge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文