是否可以通过javascript打印在谷歌文档查看器来源的iframe中打开的pdf...?出于某种原因,我希望用户在同一页面上并从同一页面打印 pdf ......
这是 iframe 的代码:
<button style="height:35px; cursor:pointer; " class="button" id="print"> <img src="images/print.png"/> <span style=" vertical-align: super; "> Print this note </span> </button>
<?php echo '<iframe id="PDFtoPrint" src="http://docs.google.com/gview?url='.JURI::root().'resources/pdf_full/'.$full_name.'&embedded=true" style="width:800px; height:1000px; " frameborder="0"></iframe>';?>
这是打印的jquery代码......
jQuery(document).ready(function($) {
$('#print').click(function(){
// window.frames["PDFtoPrint"].focus();
// window.frames["PDFtoPrint"].print(); // NOT WORKING
// var PDF = document.getElementById('PDFtoPrint');
// PDF.focus();
// PDF.contentWindow.print(); // NOT WORKING
// $("#PDFtoPrint").get(0).contentWindow.print(); // NOT WORKING
// document.getElementById("PDFtoPrint").contentWindow.print(); // NOT WORKING
});
});