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

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
LVL 1
countrymeisterAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
alorentzConnect With a Mentor Commented:
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
 
alorentzCommented:
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
 
countrymeisterAuthor Commented:
How do I attach the pdf or html file to the content to print?
0
 
countrymeisterAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.