最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Printing to a client printer from a web app - Stack Overflow

programmeradmin7浏览0评论

If I have a printer hooked directly to a pc (a kiosk with a printer), how would I go about creating the ability for a web page ( web app) to print a jpg to the kiosks printer with no user intervention other than clicking a button on the page?

If I have a printer hooked directly to a pc (a kiosk with a printer), how would I go about creating the ability for a web page ( web app) to print a jpg to the kiosks printer with no user intervention other than clicking a button on the page?

Share Improve this question edited Jan 7, 2015 at 23:40 John Saunders 162k26 gold badges251 silver badges402 bronze badges asked Oct 15, 2008 at 23:21 JeremyJeremy 46.4k71 gold badges213 silver badges352 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 8

This has been asked several times already, and the result is always that you can't do it via normal web technologies (HTML + Javascript). The best you can do is open the print dialog, and that is by design. What you can do since you control the kiosks is create some kind of browser extension (like a flash object, .Net hosted control, java applet, etc) and make that available to your page, so that it handles the printing part for you.

I solve this problems in 2 different ways:

  1. Using ActiveX
  2. Creating a protocol like myprint://PRINT_DATA

if you created an application that hosted the web browser control (rather than using a web browser directly) you could control the printing process much more directly.

(assuming using Windows + IE is possible)

here are some example articles that might help:

Configure a WebBrowser Control

Using the Web Browser Control in your C# Applications

and the ever changing MSDN docs for the WebBrowser class, which has the Print method.

From the print method remarks: "You can use this method to implement a Print button similar to the one in Internet Explorer. This method prints the current document without requiring further user input."

The other ments cover a scenario where you want to print on the puter of the web browser.

However, if you want to print to a printer connected to the web server (ie, the machine running the web application), you can use regular C# printing with the following twist: http://support.microsoft./kb/184291/

In my context, my kiosk runs both the web server and the web browser, so that solved my problem.

发布评论

评论列表(0)

  1. 暂无评论