[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

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
0
countrymeister
Asked:
countrymeister
  • 2
  • 2
1 Solution
 
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
 
alorentzCommented:
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
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now