How do I print between a web server and a local printer?

Asked

Viewed 1,088 times

0

Good afternoon I need to print a direct tax receipt from a web system. (MP 20 MI X Printer Server Locaweb X client Windows 10 X PHP System)

The point is that as there are several units using the same database I cannot use local server.

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

1 answer

1


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 because the PHP language is installed inside the server.

Since regarding the database issue is connected to multiple drives and you cannot install that 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 becomes available through cups with the lp command. From this it is possible to call in php the lp command with a shell_exec function().

The solution I adopted when I had to solve this problem was to generate the PPLA bar code and save it to a temporary file. This was done by sending 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 mapped by Linux. To remedy the problem we mapped the printer through the mac-address of the computer on which it was connected; It is possible to send anything for printing as long as the correct driver is installed. In my case we had no driver so as palliative we mapped with a CUPS Plain text driver and started sending a PPLA file for printing. ) Source: Printing in PHP

  • The tricky thing is, it’s not always the same printer.. I had adopted a command via exec right on the port by Generic text but I can’t execute the same command now that the system is online...or I’m doing it wrong... but I’ll try this way thanks!

  • Since it is not the same printer, you must write in some file or database the ports of each printer, give a name to them and make a 'combobox' button so that the user can choose the printer that wants to carry out the printing, so you allow the user to choose, similar as we normally do with desktop languages, but remember that the or printers, need to be mapped and fixed local ip to avoid problems with DNS.

Browser other questions tagged

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