Click here to Skip to main content
11,644,731 members (58,400 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
How to get client printer list?

I am using ASP.net and I want Printers installed on client machine, Please Help...
Posted 31-Oct-12 17:52pm
Edited 31-Oct-12 17:53pm
v2
Comments
John Bhatt at 1-Nov-12 2:35am
   
A foolish but Good question.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.

<html>
<head>
<script>
function printpage()
  {
  window.print()
  }
</script>
</head>
<body>
 
<input type="button" value="Print this page" onclick="printpage()">
 
</body>
</html>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.Smile | :)

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

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

  Print Answers RSS
0 OriginalGriff 680
1 jyo.net 494
2 Sergey Alexandrovich Kryukov 454
3 Afzaal Ahmad Zeeshan 404
4 CPallini 386
0 OriginalGriff 1,020
1 Sergey Alexandrovich Kryukov 673
2 DamithSL 656
3 Afzaal Ahmad Zeeshan 652
4 CPallini 555


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 1 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100