Issue
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);
});
Solution
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
Answered By - michael
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.