Solved

Can you print to a client's default printer from an ASP.NET page

Posted on 2006-11-14
4
407 Views
Last Modified: 2010-07-27
Hi !

I need to print to a client's default printer from an ASP.NET page?
The content is either pdf or html.

How can I do this. Any code samples will be great.

Thanks
H
0
Comment
Question by:countrymeister
  • 2
  • 2
4 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 17939576
You would do it in Javascript is anything.  First 2 links have code:
http://www.google.com/search?hl=en&q=default+printer+JAvascript&btnG=Google+Search 
0
 
LVL 1

Author Comment

by:countrymeister
ID: 17957493
How do I attach the pdf or html file to the content to print?
0
 
LVL 31

Accepted Solution

by:
alorentz earned 500 total points
ID: 17957589
You can't with PDF (they need to do that themselves), and for HTML...you put the Javascript in the HTML body onload event. "window.print()"
0
 
LVL 1

Author Comment

by:countrymeister
ID: 17957922
Well from what I read from the posts on this site, there is a concept to print an iframe, and attaching a pdf file as src( ihave added the snippet below).
This would bring up the print dialog on the client.
I have to agree with you on the initial question and award you the points. I will post another question on how to attach a pdf file as src to a iframe and invoke the print script from code behind.


<script type="text/javascript">
          function zPrint(oTgt)
          {
               oTgt.focus();
               oTgt.print();
          }
     </script>

<iframe id="myIFrame" style="width:0px;height:0px" src="some.pdf"></iframe>
<input type="button" value="Print PDF" onclick="zPrint(myIFrame);" />
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question