473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

print pdf page without opening

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. win=window.open("","","width=5 height=5");
  2. win.blur();
  3. win.document.location="http://www.mydomain.com/mydoc.pdf";
  4. win.print();
  5. win.close();
  6.  
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", "http://www.mydomain.com/mydoc.pdf"); 
  5. iframe.style.display = "none";
  6. window.document.body.appendChild(iframe);
  7.  
  8. var x = document.getElementById("testiframe");
  9. x.focus();
  10. x.print();
  11.  
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
2 4151
acoder
16,027 Expert Mod 8TB
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
Mission impossible
The window.print() is not propagated (inherited) in your object pdf !!!!
The pdf objects has own print !!!
Sep 5 '08 #3

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

Similar topics

1
by: weiwei | last post by:
HI I am having a problem with print friendly function with asp, I have download some code regard with print friendly, it works fine with static html information, however, I have the dynamic pages...
2
by: Piyush | last post by:
Hi, I need to print stuff on the default printer on the click of a button without opening the print box opening up. Any pointers?
5
by: Alan | last post by:
While not rs.eof <td><%=rs("InvoiceNo")%></td> <td><%=rs("Name")%></td> <td><a href="InvoicePrint.asp?WInv=<%=rs("InvoiceNo")%>"></a></td> <td>Print this invoice</td> rs.MoveNext Wend Now...
6
by: moony marouane | last post by:
Hi Everybody I have a problem opening a file with ADODB.Stream when <HTML> exists on the same page here is the code I use : =================================== <HTML> <%
1
by: ccherlet | last post by:
I'm trying to create a print link that sends the page to the printer without opening the print dialog box on the browser. I know that window.print() will open the print dialog and then the user...
0
by: shizah | last post by:
Hello My other concern is that I want to print a ASP web page which takes some parameters from the current page. How can I print that page directly without opening it. -- shizah
1
by: Sofia Zarin | last post by:
HelloMy other concern is that I want to print a ASP web page which takes some parameters from the current page. How can I print that page directly without opening it.Please help me out regarding...
2
by: bob | last post by:
Hi, I have a page that has a collection of things which it passes to a second 'print' page using a session variable. The print page has buttons for moving though the collection and the user ...
1
by: Mike | last post by:
Hi, I have a web application written in asp.net and C#. It generates a bunch of pdf file using crystal report. Now I need to batch print all those pdf files from a web page to user's local...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.