PDF斑点 - 弹出窗口不显示contnet [英] PDF Blob - Pop up window not showing contnet

查看:297
本文介绍了PDF斑点 - 弹出窗口不显示contnet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在这个问题的的最后几天。随着试图显示在流上没有运气<嵌入SRC方式> 标签,我只是想将其显示在一个新的窗口。

新窗口显示PDF的仅控制

任何想法,为什么PDF的内容没有显示?

code:

  $ http.post('/ fetchBlobURL',{myParams})。成功(功能(数据){
    var文件=新的Blob([数据] {类型:应用程序/ PDF'});
    变种fileURL = URL.createObjectURL(文件);
    window.open(fileURL);
});


解决方案

您需要设置的responseType arraybuffer 如果你想创建一个一滴

  $ http.post('/ fetchBlobURL',{myParams},{responseTyp的:arraybuffer'})
   .success(功能(数据){
       var文件=新的Blob([数据] {类型:应用程序/ PDF'});
       变种fileURL = URL.createObjectURL(文件);
       window.open(fileURL);
});

了解更多信息:<一href=\"https://developer.mozilla.org/en-US/docs/Web/API/XMLHtt$p$pquest/Sending_and_Receiving_Binary_Data\">Sending_and_Receiving_Binary_Data

I have been working on this problem for the last few days. With no luck on trying to display the stream on <embed src> tag, I just tried to display it on a new window.

The new window shows pdf controls only )

Any idea why the content of the pdf is not showing?

CODE:

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

解决方案

You need to set the responseType to arraybuffer if you would like to create a blob from your response data:

$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);
});

more information: Sending_and_Receiving_Binary_Data

这篇关于PDF斑点 - 弹出窗口不显示contnet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆