This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing through Javascript? Urgent!!!

 
Gaurav Jain
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a PDF document which is kept on a certain location on the server.My requirement is to print that particular document on the client side without opening up that document, using javascript.
Is this possible? If yes then any pointers will be highly appreciated.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are going to have to open up the document in some method or another! There is no other way of doing it.

The best thing to do is open up a hidden i-frame and print that frame:


You can print the iframe with:


Eric
 
Gaurav Jain
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
Since the frame is hidden the file whcih is mentioned in the src of IFRAME is not getting printed.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try making it 0 pixels high, or show it breifly when it is printed.

Eric
 
Sandeep Deshmukh
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody

I want to do something similar to Gaurav.
But my question is the pdf file going to be downloaded to client machine.
Also i want to know how to give path of the pdf in src tag of frame. will it be absolute path of it on the server or if relative how to give relative path or url.

With regards
Sandeep
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Linking to the pdf is just like linking to any other file/html page located in your web directory.

If the files is viewed/opened on a page, it will be saved in their cache.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic