Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
How to get client printer list?

I am using ASP.net and I want Printers installed on client machine, Please Help...
Posted
Updated 31-Oct-12 17:53pm
v2
Comments
John Bhatt 1-Nov-12 2:35am    
A foolish but Good question.

You can use javascript function window.Print()
This will list you client machine printers and print your page.
Below is code that you can try yourself.

XML
<html>
<head>
<script>
function printpage()
  {
  window.print()
  }
</script>
</head>
<body>

<input type="button" value="Print this page" onclick="printpage()">

</body>
</html>
 
Share this answer
 
A Web application does not have access to client systems, for a good reason. Imagine for a second that it was possible. Would any reasonable user like that some unknown site could discover printers or other equipment? This even sounds scary.

This article explains how to print using ASP.NET:
http://www.c-sharpcorner.com/uploadfile/rahul4_saxena/printing-in-Asp-Net/[^].

Note that the server side only provides printable content, and all the detail of printing selection, printing quality and other options totally happens on the client side, in a way designed in client's OS. This is the only reasonable and safe way.

Even this way seems to be a bit too redundant and intrusive, to my taste. I personally think that the user knows better when to print, what to print and how. You better just provide printer-friendly content. A while ago, some special "printable version" anchors were in fashion, but you should admit that this is not elegant, especially in terms of site maintenance. Much better approach is using CSS media types. Please see:
http://www.w3schools.com/css/css_mediatypes.asp[^].

See also my past answer on the topic:
Print to LPT1 port using ASP.net[^].

—SA
 
Share this answer
 
v2
No.. It is not possible. A web application has very limited access to the client machine's hardware. At the most you can call the default printer to popup the print dialog.

The limitation on getting the printer list is a security feature so that a hacker should not get the printer details to hack it to print the restaurant menus whenever a user accesses the website.:)

You should leave the choice of printing to the user because the website is yours, not the printer..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900