Printing in PHP

3

I am developing a stock management system for the company and the customer needs the system to print the labels on a special printer for labels (Datamax I-4210) registered products.

The system is web-based and stays on a server in-house and is networked with the printer.

Yesterday I spent all day researching solutions but I did not succeed. Actually I know that it is possible to send commands to printers by socket , but it is my first experience with such functionality and I am really well lost. I have no problem sending sockets and until sending commands, the problem is that I can connect to the printer to send the commands.

The problem itself is finding the printer's IP and port so I can send the sockets with the commands. In the company my client already uses a desktop program called BarOne and he can print the labels. Probably because it is a desktop software it manages to network the printer and get the data it needs to somehow send the commands. The same can not be used by me since the system is in PHP and I can not get this data from the printer.

    
asked by anonymous 06.02.2015 / 13:03

1 answer

1

I have already had to solve a scenario close to this.
If you use Linux you can map the network printer so that it is available through the cups with the command lp. From this it is possible to call in php the command lp with a function of type shell_exec () .

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

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 where it was connected;
  • You can send anything for printing as long as you have the correct driver installed. In my case we did not have driver so as palliative we mapped with a CUPS plain text driver and started sending a PPLA file for printing.
  • 06.02.2015 / 14:19