Is there a way to print a pdf document without opening it, if user just select the pdf files in the checkbox and click a button?
I tried the following two methods, but both fail.
1. open a new window:
- win=window.open("","","width=5 height=5");
-
win.blur();
-
win.document.location="http://www.mydomain.com/mydoc.pdf";
-
win.print();
-
win.close();
-
2. use iframe:
- iframe = document.createElement("IFRAME");
-
iframe.setAttribute("id","testiframe");
-
iframe.setAttribute("name","testiframe");
-
iframe.setAttribute("src", "http://www.mydomain.com/mydoc.pdf");
-
iframe.style.display = "none";
-
window.document.body.appendChild(iframe);
-
-
var x = document.getElementById("testiframe");
-
x.focus();
-
x.print();
-
Did I miss anything? Or it is completely impossible to print pdf without opening it. Thanks a lot!
P.S. I found this forum is very helpful. It helps me solve many problems, so I posted this message first time here. Thanks for your answer in advance!