gpt4 book ai didi

javascript - PDF Blob - 弹出窗口不显示内容

转载 作者:IT王子 更新时间:2023-10-29 03:14:00 26 4
gpt4 key购买 nike

我一直在研究 this problem最近几天。尝试在 <embed src> 上显示流时没有运气标签,我只是试图在新窗口中显示它。

新窗口显示 PDF 仅控件 enter image description here )

知道为什么 pdf 的内容没有显示吗?

代码:

$http.post('/fetchBlobURL',{myParams}).success(function (data) {
var file = new Blob([data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
});

最佳答案

如果您想从您的响应数据创建一个blob,您需要将responseType设置为arraybuffer:

$http.post('/fetchBlobURL',{myParams}, {responseType: 'arraybuffer'})
.success(function (data) {
var file = new Blob([data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
});

更多信息:Sending_and_Receiving_Binary_Data

关于javascript - PDF Blob - 弹出窗口不显示内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21729451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com