473,411 Members | 1,918 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,411 software developers and data experts.

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 7672
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my...
4
by: Fred | last post by:
I'm a newbie to JavaScript so be gentle. You know that funky IE margin issue that causes the right side of the page to get cut off when the user prints the html document?...
1
by: nospam | last post by:
All I am trying to achieve the following: Main window page's asp code writes the following line to launch a popup window (note the IFRAME has to be in the popup window, it cannot be in the...
4
by: Machi | last post by:
I have created a asp.net web form with one datagrid which is used to display some information in tabular format. However, in the page, there are 2 buttons which are "Save" and "Print", when i save...
4
by: rom | last post by:
I need to print a html table when the user clicks on a key. the problem is that i don't want the printer dialog box to appear. i guess this is impossible in javascript so i think to create an...
6
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page...
0
by: agarwalsunitadhn | last post by:
hi.. How will i use print and print preview option. I have to print only a part of a page. for that i declare in a div and give that a id and then using java function to print that portion but my...
5
by: bdy120602 | last post by:
Is it possible, when a user or viewer of your Web page, prints or takes a screen shot of a Web page with mousover (roll-over) text in it, to have that text printed or captures as part of the screen...
2
by: bob | last post by:
Hi, I have a page that has a collection of things which it passes to a second 'print' page using a session variable. The print page has buttons for moving though the collection and the user ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.