我知道这里有一些链接和答案,但它们不适合我的问题...... 我在浏览器中有一个打开的选项卡,带有要打印的pdf,我想在用户点击“确定”(打印)按钮后立即自动关闭它。
我知道有很多方法可以使用javascript onbeforeprint()和onafterprint(),但是你可以想象我不可能从pdf文件中调用它们:D - 我看到浏览器的插件是我的最佳镜头......任何想法都有吗?
答案 0 :(得分:0)
为什么不将PDF设置为iframe并以这种方式打印,
我正在解决打印盒关闭页面问题。
<script>
$(document).ready(function(){
// timeout is used to give the browser a chance to load everything before executing the close
setTimeout(function(){ window.close();},300);
// before unload print the window, then the window closes if it was opened with window.open()
$(window).bind("beforeunload",function(){
window.print();
});
});
</script>
除非您使用浏览器内部PDF查看器,否则我不知所措。