Window.open 二进制数据 pdf 正在下载但不显示 pdf:Javascript

Window.open binary data pdf is downloading but not displaying pdf :Javascript

嗨,我有 base64 的 pdf 二进制数据,我正在尝试在新 window 中打开, 它正在下载但未打开,新的 window 是空的,大约空白

<a click="openfile(sampledoc)"  href="#"><img src="some.png" /></a>

function openfile(binaryData){
 window.open('data:application/pdf;base64,'+binaryData, 'samplepdf', 'width=700px,height=600px');
}

Pdf 正在完美下载,但未在打开的文件中显示 window。

Pdf 在 firefox 的新标签页中显示,但在 chrome 中下载但不显示

我在 firefox 和 chrome 上都试过了,它是在新的 window 中打开的,而不是下载的。

window.open("data:application/pdf;base64,JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwogIC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAvTWVkaWFCb3ggWyAwIDAgMjAwIDIwMCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0KPj4KZW5kb2JqCgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAgL1Jlc291cmNlcyA8PAogICAgL0ZvbnQgPDwKICAgICAgL0YxIDQgMCBSIAogICAgPj4KICA+PgogIC9Db250ZW50cyA1IDAgUgo+PgplbmRvYmoKCjQgMCBvYmoKPDwKICAvVHlwZSAvRm9udAogIC9TdWJ0eXBlIC9UeXBlMQogIC9CYXNlRm9udCAvVGltZXMtUm9tYW4KPj4KZW5kb2JqCgo1IDAgb2JqICAlIHBhZ2UgY29udGVudAo8PAogIC9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCjcwIDUwIFRECi9GMSAxMiBUZgooSGVsbG8sIHdvcmxkISkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4gCjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAwMDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9vdCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G", "mypdf", "width=700px,height=600px");

可能与您机器上的 chrome 设置有关。请换台机器试试。

Opening/printing pdf 在浏览器上有问题。有的浏览器用adobe plugin打开,有的用pdf.js,有的用其他方式,有的用下载代替打开