'프린트' 버튼 클릭시 pdf 파일 인쇄하기 창 띄우기
function printTrigger(elementId) {
var getMyFrame = document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
};
/* 영어 매뉴얼 인쇄 */
jQuery("#Manuel_Print_EN").click(function(){
printTrigger('iFramePdf_EN');
});
1. 버튼에 아이디 입력 : #Manuel_Print_EN
2. 컬럼에 다음 코드 입력 : <iframe id="iFramePdf_EN" src="xxx.pdf" style="width:1px; height:1px; opacity:0;"></iframe>
===========================================================================
Re: How to print Pdf file through window.Print() ?
Sep 30, 2013 06:47 PM|LINK
A function to house the print trigger:
function printTrigger(elementId) {
var getMyFrame = document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
}
An button to give the user access: (an onClick on an a or button or input or whatever you wish)
<input type="button" value="Print" onclick="printTrigger('iFramePdf');" />
An iframe pointing to your PDF:
<iframe id="iFramePdf" src="myPdfUrl.pdf" style="dispaly:none;"></iframe>
Source: http://stackoverflow.com/questions/687675/can-a-pdf-files-print-dialog-be-opened-with-javascript
※ 익스플로러, 파이어폭스에는 정상 작동 안함
출처 : ASP.NET forum : How to print Pdf file through window.Print() ?
원출처 : https://stackoverflow.com/questions/687675/can-a-pdf-files-print-dialog-be-opened-with-javascript
'jQuery' 카테고리의 다른 글
[javascript] 파일첨부시 특정 파일확장자만 선택 / input type="file" 초기화 (1) | 2018.10.14 |
---|---|
[jQuery] Plugin - fullPage.js (0) | 2018.10.07 |
textarea 글자수 제한 (0) | 2018.06.28 |
[jQuery] clone() - text() 또는 html() 사용시 텍스트만 지우고 태그는 남기는 방법 (0) | 2018.06.18 |
[jQuery] Object의 특정 클래스 포함여부 확인/엘리먼트의 객체 존재여부 체크 - hasClass, is 함수, length 속성 (0) | 2018.06.17 |