admin 管理员组文章数量: 1086019
I am working on a mobile application.we are using jquery-mobile.
we have an option to view or download the records in pdf format. I dont have the control on backend. I will get the pdf data in json object as an ajax response.I want to read that data and display in a pdf. I have next and previous links are also in the page so we need to display pdf in a div.
var data = {
.... : ....,
.... : ....,
"pdfstream" : "KioqKioqKioqKioq......",
..... : ....
}
am able to read all the data but not sure how can i read that bytestream and display as an pdf in the page.
UPDATE: My code is working fine. But the bytestream which am getting from server is wrong.
var obj = $('<object type="application/pdf" width="100%" height="100%" border="2"></object>');
obj.attr('data','data:application/pdf;base64,'+bytestream);
$('#divContainer').append(obj);
its working fine in all browsers expect in IE. Need to verify why its not working in IE.
I am working on a mobile application.we are using jquery-mobile.
we have an option to view or download the records in pdf format. I dont have the control on backend. I will get the pdf data in json object as an ajax response.I want to read that data and display in a pdf. I have next and previous links are also in the page so we need to display pdf in a div.
var data = {
.... : ....,
.... : ....,
"pdfstream" : "KioqKioqKioqKioq......",
..... : ....
}
am able to read all the data but not sure how can i read that bytestream and display as an pdf in the page.
UPDATE: My code is working fine. But the bytestream which am getting from server is wrong.
var obj = $('<object type="application/pdf" width="100%" height="100%" border="2"></object>');
obj.attr('data','data:application/pdf;base64,'+bytestream);
$('#divContainer').append(obj);
its working fine in all browsers expect in IE. Need to verify why its not working in IE.
Share Improve this question edited Jun 10, 2013 at 19:35 sai sudhakar asked Jun 8, 2013 at 6:24 sai sudhakarsai sudhakar 2041 gold badge2 silver badges8 bronze badges2 Answers
Reset to default 2Did you try with this
http://mozilla.github./pdf.js/
Moreover you can visit the following link, the question is almost similar:
How to display a PDF stream in a browser using javascript
Don't show it in ajax show the pdf as source of an iframe then it will work
本文标签: javascriptHow to render a pdf from bytestream in ajax responseStack Overflow
版权声明:本文标题:javascript - How to render a pdf from bytestream in ajax response - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744086261a2531185.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论