打印iframe中的PDF [英] print PDF present in iframe
问题描述
如何打印iframe中的PDF?
我想在iframe中打印pdf。
我能够使用浏览器IE和Chrome进行打印,但它会给FireFox,Safari和Opera带来问题。
我尝试过如下:
< pre lang =c#> function printIframe(){
if (navigator.userAgent.indexOf( Firefox)!= -1){
// 这不起作用
var frame_window = window.frames [ my_iframe];
frame_window.print();
}
else if (navigator.userAgent.indexOf( MSIE)!= -1){
// 工作
var x = document.getElementById( pdfDocument);
x.print();
}
else if (navigator.userAgent.indexOf( Chrome)!= -1){
// 正常工作
document.my_iframe.focus();
document.my_iframe.print();
}
其他 {
// 不工作
// Safari浏览器或其他
// document.getElementById('my_iframe')。focus();
// document.getElementById('my_iframe')。onload = setTimeout('iframe.print()',2500) ;
// var ifWin = document.getElementById('my_iframe')。contentWindow;
// ifWin.focus();
// ifWin.print();
// printpdf();
}
}
请指导我这个。
谢谢。
这个解决方案适用于Java,但原则应该是可行的申请。
它针对Safari和Chrome。
http://stackoverflow.com/questions/472951/how-do-i-print-an-iframe-from-javascript- in-safari-chrome [ ^ ]
How to print PDF which is present in iframe?
I want to print pdf present in iframe.
I am able to print with browsers IE and Chrome, but it is giving problems with FireFox, Safari and Opera.
I have tried as follows:
function printIframe() {
if (navigator.userAgent.indexOf("Firefox") != -1) {
//This is not working
var frame_window = window.frames["my_iframe"];
frame_window.print();
}
else if (navigator.userAgent.indexOf("MSIE") != -1) {
//working
var x = document.getElementById("pdfDocument");
x.print();
}
else if (navigator.userAgent.indexOf("Chrome") != -1) {
//working
document.my_iframe.focus();
document.my_iframe.print();
}
else {
//not working
// Safari browser or other one
// document.getElementById('my_iframe').focus();
// document.getElementById('my_iframe').onload = setTimeout('iframe.print()',2500);
// var ifWin = document.getElementById('my_iframe').contentWindow;
// ifWin.focus();
// ifWin.print();
//printpdf();
}
}
Please guide me for this.
Thanks.
This solution is for Java, but the principle should be possible to apply.
It addresses Safari and Chrome.
http://stackoverflow.com/questions/472951/how-do-i-print-an-iframe-from-javascript-in-safari-chrome[^]
这篇关于打印iframe中的PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!