2014-01-20 2 views
1

자바 스크립트로 Google 문서 뷰어가 제공하는 iframe에서 열리는 PDF를 인쇄 할 수 있습니까? ...자바 스크립트로 Google 문서 뷰어로 작성된 iframe에서 PDF 파일을 인쇄

<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 코드입니다 : 내가 사용자가 동일한 페이지에하고 같은 페이지에서 PDF를 인쇄 할 몇 가지 이유 ... 여기

은 iframe 대응의 코드는
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 


    }); 
}); 

답변

1

아니요, JavaScript의 동일 원산지 정책으로 인해 불가능합니다. JavaScript는 다른 도메인의 프레임에로드 된 페이지의 DOM을 조작하거나 상호 작용할 수 없습니다. 내가 아는 한 한 가지 예외가 있지만 Google에서는 귀하의 사이트가 귀하의 사이트를 그렇게하도록 허용 할 것을 명시 적으로 요구합니다. 동일한 출처 정책에 대한 자세한 내용은 여기를 참조하십시오. https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

관련 문제