Solved

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

Posted on 2006-11-14
4
405 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now