Can you be a little bit more explicit with this:
var thePDFObj = document.getElementById("p
thePDFObj.src = "http://www.mywebsite.com/
Thanks.
Main Topics
Browse All TopicsHi,
I have this function to print PDF on a web page, however I need to print multiple PDF files and I cannot place an imaga for every file.
Here is the code:
<script>
function doit(elementId) {
var x = document.getElementById(el
//.document.plugins.whatev
x.click();
x.setActive();
x.focus();
x.print();
}
</script>
<embed id="pepe" src ="http://www.mywebsite.com
<button onclick="doit('pepe')">Pri
Can I change the: src ="http://www.mywebsite.com
Or is there any other solution to print PDF from JS?
Thanks in advance!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Can you be a little bit more explicit with this:
var thePDFObj = document.getElementById("p
thePDFObj.src = "http://www.mywebsite.com/
Thanks.
Oh, you asked if you could switch the src of the pdf file, in the "pepe" element. If you just wanted to use that one element "pepe", but you wanted to change the src dynamically, you'd use javascript to replace the src with whatever URL you wanted.
The first line of the code gets a reference to that object, by it's ID "pepe"...then the second line of code actually changes the src (switches the URL)....does it work?
The problem I've run into using the following:
thePDFObj.src="some pdf url";
thePDFObj.print();
Is that the print() function may be called before the entire PDF document is loaded. One solutoin I have found (it is IE specific though) is something like the following:
<object id="Pdf1" type="application/pdf" style="width:0px;height:0p
var obj = document.getElementById('P
obj.src=url;
obj.printWithDialog();
the printWithDialog() method waits for the entire pdf to be loaded before it opens the print dialog.
I've tried a lot of different solutions like loading the pdf into and Iframe with and onload event and such but none have worked for me.
Business Accounts
Answer for Membership
by: geodan7Posted on 2007-05-31 at 12:18:34ID: 19190719
This allows you to print to a pdf:
eveloper/a rticle.asp ? ContentID =printing_ pdfs_using _javascrip t
epe"); mydocument 2.pdf";
http://www.planetpdf.com/d
Or, you could just say:
var thePDFObj = document.getElementById("p
thePDFObj.src = "http://www.mywebsite.com/