How to print from a web application to a local printer with C#

Asked

Viewed 2,246 times

4

I need to program in web some resources that perform local impression, where text and commands are sent to a specific device without the user interaction. For example the issuance of labels on Zebra and Argox equipment and coupon printing nonfiscal in Bematech MP20 printers.

What is the most efficient way to resolve this issue with C#?

The only possibility I thought was to create a support application to be installed on the desktop, but I’m not sure, would be two possibilities:

1) Develop an application as a WCF service installed on the desktop and call the web application. (I believe that in this case there would have to be firewall configuration and port targeting, to allow access and this would not be practical due to the volume of users accessing from different environments)

2) Create a server service (ASMX) and a desktop application that periodically consults the service to check for activity to perform, then perform the task locally. (But it worries me how much this service will be occupied even when in the impression)

Do you think any of these options are feasible? How would you solve?

  • Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.

2 answers

2

The server side you can do as you please as long as it serves the information you need the way you need it. Particularly I avoid making web because it has disadvantages. It’s fashionable that people want it to be web. Making web has the advantage to websites, In some cases far rarer than people realize may be useful for applications, but in general the user experience is impaired and not a good idea. Unfortunately it looks like something no one gives more. The performance of serving by HTTP is not good.

The client side really needs to do something that has full access to the computer and should be a desktop application. You can even make the application run on the browser and a desktop helper, but it is gambiarra and rarely justified. The user experience will suffer.

Personally I would not use WCF, I prefer to use direct TCP to communicate with the server. If you want to make web on the server even then communicate by HTTP. I find WCF a tough ride to handle, slow and heavy, but I prefer the WCF well done by TCP than web application.

Setting up firewall is no problem, can be done even programmatically, I would not stop doing something better for life because it will give an extra job once. I don’t understand why people get it into their heads that this is a problem.

Even if I choose to do HTTP, I would use ASP.NET Core or at least ASP.NET MVC, I wouldn’t go from classic ASP.NET at all, it’s obsolete. So is MVC, but it’s new.

If you do it the right way there will be no problems in processing overload. Can do without fright it checks periodically. Or you can make the server a subscription system that the server notifies you when you have something relevant to the subscribers. It depends on the volume of each thing and the need for agility in having the news, one or the other can be better.

0

I participated in several projects using similar structure, but the printers were on the server side.. Systems where I had an ASP.NET application and this application performed prints on Zebra printers, including I have the framework ready for printing if I need it, I can put it on Github.

What I did was create a Webservice and publish it on the server where the printer is installed, remember that the Webservice (ASMX) running on IIS (Application Pool) should have permissions to perform the printing, that was one of the problems, then we put a user with permissions in the Webservice IIS Applicationpool to perform the printing.

So in the call Print of [WebMethod] received as parameter the printer name.

The application has been running for a few years and we never had any problems, for the project in question was the best solution, where we had more than 10 Zebra printers installed on the server.

  • 1

    Your situation seems to me to be the opposite of that of your colleague, although the solution is valid. I believe his printer should be on the client side, not on the server like yours.

  • 1

    Yes, I understand, and I understand his impasse of having to install local App’s on the client side depending on the printers.. situation a little delicate even.

  • yes, I only saw something working this way using activeX, which in the situation performed ECF prints.

  • 1

    This Even the Printer is on the Client’s side, and the issue is that many of these customers do not have a technician to manage the network, and use the most valuable types of routers on the infra-local complicating if a local service is published. I’m still in doubt!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.