469,356 Members | 2,213 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

print pdf using javascript

Hi,

I have a web application written in asp.net and C#. It generates a
bunch of pdf file using crystal report. Now I need to batch print all
those pdf files from a web page to user's local printer.

Could anyone provide any suggestions?

By the way, I found some javascript code which was claimed to print
pdf from a web page. But when I tried, the page pops up a warning
message:

"File does not begin with '%PDF-'. "

Since title of the pop up window is 'Adobe Reader', I guess that the
message is emitted by Adobe Reader. Does anyone know what the message
mean ?

My code is :
<html>
<head>
<script>
function doit() {
var x = document.getElementById("doodad");
x.print();
}
</script>

</head>
<body>
<embed id="doodad" src ="c:/test2.pdf" width="0" height="0"
name="whatever">
<button onclick="doit()">howdy</button>
</body>
</html>
Thanks ahead !
Nov 15 '08 #1
1 7414
On 2008-11-15 05:51, Mike wrote:
I have a web application written in asp.net and C#. It generates a
bunch of pdf file using crystal report. Now I need to batch print all
those pdf files from a web page to user's local printer.
I don't think that's possible, or at least not without the help of
ActiveX objects.
By the way, I found some javascript code which was claimed to print
pdf from a web page.
If that's the code you've posted, it would only open one PDF document
with the Acrobat Reader plugin (if it even works).
But when I tried, the page pops up a warning
message:

"File does not begin with '%PDF-'. "
That means that the PDF plugin doesn't recognize the resource as a valid
PDF file ("%PDF-...." is the PDF file header). The file may be missing,
or invalid, or the security settings don't allow opening local files.
<script>
function doit() {
var x = document.getElementById("doodad");
x.print();
DOM nodes don't have a print() method.

Why don't you just merge the PDF files on the backend, and let the user
print it all from a single file?
- Conrad
Nov 17 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Machi | last post: by
4 posts views Thread by rom | last post: by
6 posts views Thread by CSharpguy | last post: by
5 posts views Thread by bdy120602 | last post: by
2 posts views Thread by bob | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.