有没有一种方法可以在IE中生成PDF预览 [英] Is there a way to generate a preview of PDF in IE
本文介绍了有没有一种方法可以在IE中生成PDF预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在IE浏览器中是否总能生成PDF预览?
Is there anyway at all to generate a preview of a PDF in an IE browser?
我知道您可以在Chrome或Firefox中使用iframe,在IE中使用blob,但是它们都需要自己的代码,我正在寻找可以在跨浏览器中使用的东西.
I know that you could use an iframe in either Chrome or Firefox, and a blob in IE, but they both require their own code, I'm looking for something that will work cross browsers.
推荐答案
最终找到了一个解决方案,该解决方案为所有浏览器都支持的PDF文件生成了一个浏览器内预览窗口!
Finally found a solution, that generates an in-browser preview window for a PDF file that is supported by all browsers!
这是我的代码(我已在输入框中输入内容,以便任何人都可以测试任何PDF URL):
Here's my code (I've put in an input box so that anyone could test any PDF URL):
<div class="wizard-content">
<div class="col-md-6">
<input id="pdfsrc" class="form-control">
<a id="refresh" href="#" class="btn btn-lg btn-success">Refresh PDF</a>
</div>
<div id="myDiv" class="col-md-6">
<object id="objsrc" data="" type="application/pdf" style="width:100%;height:100%">
<embed id="embsrc" src="" type="application/pdf" style="width:100%;height:100%/">
</object>
</div>
</div>
JS:
$(function() {
$("#refresh").click(function() {
var url=document.getElementById('pdfsrc').value;
$("#objsrc").attr("data", url);
$("#embsrc").attr("src", url);
var container = document.getElementById("myDiv");
var content = container.innerHTML;
container.innerHTML = content;
})
})
这篇关于有没有一种方法可以在IE中生成PDF预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文