简体   繁体   中英

cannot print popup displaying pdf file

I have a php file with the following code:

<?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. But the same code without the pdf filename ie

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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