Connecting Tech Pros Worldwide Help | Site Map

JavaScript function to print a pdf file.

  #1  
Old July 20th, 2005, 11:24 AM
Brian Hanson
Guest
 
Posts: n/a
Hi,

I am trying to write a javascript function that gets called from a
within an asp.net application to print a pdf file(s) programmatically.
I am a pretty experienced developer in several languages, but I'm a
serious newbie when it comes to anything sounding like javascript. I
have searched the forums and found some code that (I think) will do
exactly what I am looking for. Unfortunatelly, I cannot get it to
work and was hoping someone who knows javascript could help me out.

Here's the code from an earlier posting:

<embed src ="<filePath>" width="0" height="0"
name="pdfFile">

<script_Language_="javaScript">
function print(){
document.all.pdfFile.print();
}
</script>


Here's my code:

<embed src ="<c:\drawings\>" width="0" height="0"
name="drawing7.pdf">

<script_Language_="javaScript">
function print(){
document.all.pdfFile.print();
}
</script>


I have also set the file path to include the file name and removed the
underscores from script_language_ and played with the <>, but still no
luck. Once I get a function that will work on its own, I can convert
it to run in the .net app.

Thanks
  #2  
Old July 20th, 2005, 11:25 AM
asdf asdf
Guest
 
Posts: n/a

re: JavaScript function to print a pdf file.


Hello, my code is lame, but it works for me. Obviously not all of it
is necessary, but it gives you an idea of some of the things I was
trying to do.

<html>
<head>
<script>
function doit() {
var x = document.getElementById("doodad");
//.document.plugins.whatever
x.click();
x.setActive();
x.focus();
x.print();
}
</script>

</head>
<body>
<embed id="doodad" src ="D:\Documents and
Settings\ron\Desktop\eth_cli.pdf" width="550" height="550"
name="whatever">
<button onclick="doit()">howdy</button>
</body>
</html>
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print PDF file using javascript without opening it sachins answers 1 June 19th, 2009 07:01 PM
print pdf using javascript Mike answers 1 November 17th, 2008 01:45 AM
Print Pdf directly (without preview) from client side (using asp.net) AP No spam answers 2 November 18th, 2005 03:47 PM