By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
461,942 Members | 764 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 461,942 IT Pros & Developers. It's quick & easy.

print pdf page without opening

P: 1
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:

Expand|Select|Wrap|Line Numbers
  1."","","width=5 height=5");
  2. win.blur();
  3. win.document.location="";
  4. win.print();
  5. win.close();
2. use iframe:
Expand|Select|Wrap|Line Numbers
  1. iframe = document.createElement("IFRAME");
  2. iframe.setAttribute("id","testiframe");
  3. iframe.setAttribute("name","testiframe");
  4. iframe.setAttribute("src", ""); 
  5. = "none";
  6. window.document.body.appendChild(iframe);
  8. var x = document.getElementById("testiframe");
  9. x.focus();
  10. 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!
Aug 18 '08 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 15k+
P: 16,027
I don't know if what you're trying will be possible (never tried it myself), but what I can say is that you should wait for the iframe to enter the DOM before trying to access it. It's not available immediately, so you could use a setTimeout and check its existence before attempting to access and print it.
Aug 19 '08 #2

P: 9
Mission impossible
The window.print() is not propagated (inherited) in your object pdf !!!!
The pdf objects has own print !!!
Sep 5 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.