How to perform prints between a Web server and a local printer?

Good afternoon I need to print a non-tax receipt directly from a web system. (MP 20 printer MI X LocaWeb Server X Windows 10 Client X PHP System)

The problem is that since there are multiple units using the same database I cannot use local server.

Is there any means to connect the LPT1 or usb printer or even run a file .bat to fire this impression on the local machines?

Author: Maicon Herverton, 2016-12-20

1 answers

Thiago, you are using Web language, obviously installed on a server. Of course, if you had physical access to the server, you would connect your printer over a local network and it would work normally, since the PHP language is installed inside the server.

Since with regard to the issue of the database is connected to several drives and you can not install this local system, it is in fact necessary that you do the following:

  1. make a connection through a VPN with the networked printer on some desktop computer. Source: https://stackoverflow.com/questions/6049591/how-can-i-make-a-website-connect-directly-to-a-printer-so-that-it-can-print-out

Or ( 2. If you use Linux you can map the network printer so that it is available through cups with the lp command. From this it is possible to call in php the lp command with a function of type shell_exec().

The solution what I adopted when I had to solve this problem was to generate the barcode in PPLA and save to a temporary file. Once this was done, it was enough to send the LP command to CUPS and it turned to capture the file and print.

Some important considerations before adopting this solution:

The printer must be mappable by Linux. To fix the problem we mapped the printer through the mac-address of the computer on which it was connected; You can send anything to printing as long as you have the correct driver installed. In my case we had no driver so as a palliative we mapped with a CUPS plain text driver and started sending a PPLA file for printing. ) Source: print in PHP

 1
Author: Maicon Herverton, 2017-05-23 12:37:31