File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Printing file without opening it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Printing file without opening it" Watch "Printing file without opening it" New topic

Printing file without opening it

Rohit Ahuja
Ranch Hand

Joined: Oct 04, 2001
Posts: 121
Hi guys,
I have a JSP page which has a hyperlink to a pdf file. I want to print this PDF file without opening it... Can someone help me out with this, and it is real fast and urgent...

Face Off.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You are going to have to open the file in order for it to print... Now you have 2 options. Since you are going to be opening a pdf, it is going to take control of the browser. You are not going to be able to run any commands to print it.
There is another method. You can use frames and have the top frame(zero height) print the bottom frame containing the pdf and close the entire window after calling print. BUT the problem you are going to run into is the following,...You would not know how long to set the timeout for since you do not no page loading time. 2 when it says to print, the print dialog is going to pop up so it will not be so seamless when it closes, and some browsers may not even want to print it.
Sure I lost you with my bad grammer.....
Pain in the
But this is good since I would not want someone printing 1000 pages on my printer when I visit a website!
Persoanlly I would on the link and print out this form....
Chris De Vries
Ranch Hand

Joined: Dec 05, 2002
Posts: 65
You can try the following:

Should work on any unix machine with wget and xpdf installed, and a postscript printer or interpreter. Should also work with windows under cygwin.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Sending this to the HTML and Javascript forum, since it's more dealing with the proper use of hyperlinks and all that gobbledy gook Eric is talking about
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

This is a dupe of this topic in the JSP forum.
I think a server-side approach is best, but in any case, one of these should be closed and refer to the other. Since I can, I'm closing the topic in JSP and referring it here.
(Though I actually think Servlets is the most appropriate locale.)

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Printing file without opening it
It's not a secret anymore!