简体   繁体   English

无法打印显示pdf文件的弹出窗口

[英]cannot print popup displaying pdf file

I have a php file with the following code: 我有一个带有以下代码的php文件:

<?php

?>
<form action="" id="f1" name="f1">
    <input type="button" name="preview" value="Open PDF" onclick="showPDF()" />
</form>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
    function showPDF(){
        var newwin=window.open("pdf.pdf","Window1","menubar=no,width=430,height=360,toolbar=no");
        newwin.print();      
    }
</script>

It opens up a popup window with pdf file inside it BUT fails to open the print dialog box. 它会打开一个带有pdf文件的弹出窗口,但无法打开打印对话框。 But the same code without the pdf filename ie 但是没有pdf文件名的相同代码,即

var newwin=window.open("","Window1","menubar=no,width=430,height=360,toolbar=no");

opens up the popup window and show the print dialog box. 打开弹出窗口,并显示“打印”对话框。

Can anybody provide me a solution to this 有人可以为我提供解决方案吗

这有效吗?

newwin.printWithDialog();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM