473,414 Members | 2,019 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,414 software developers and data experts.

JavaScript function to print a pdf file.

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
Jul 20 '05 #1
1 107737
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>
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: e | last post by:
I've been having an extremely difficult time finding an answer to this in IE / js groups, so I thought I'd try here. I've got an aspx page that delivers loads of report data into custom-named...
4
by: Nate Murray | last post by:
Hey all, I'm having a strange PHP (4.3.10) problem that seems to have something to do with javascript. This is a bit complex, so hold on to your hats. My issue is that a single function is...
1
by: KRISHNA PRAVI | last post by:
the error is "runtime error object expected" here is the code....................................................................................... <script language="javascript"...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.