Printing in PHP

Asked

Viewed 958 times

3

I am developing an enterprise inventory management system and the customer needs the system to print the labels on a special label printer (Datamax I-4210) the registered products.

The system is web and is on a server in the company itself and is networked with the printer.

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

The problem itself is to find the IP and the printer port for me to 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 can network manipulate the printer and get the data it needs to somehow send the commands. The same cannot be used by me since the system is in PHP and I can’t get this data from the printer.

  • But if you can send sockets you must be connected. It is difficult for you to see which address and port the printer is connected to and put them in the code?

  • I guess you didn’t understand. I actually didn’t send sockets, I said sending them wouldn’t be the problem IF I had the IP and printer port. The problem itself is this. Know the IP and port and managed to connect besides knowing if it is a UDP or TCP connection...

  • And why can’t you look at which IP and port the press is on? Do people keep changing all the time? If you stay, there’s a reason for this?

  • Then as I had said above, yesterday I spent the day looking for solutions and in relation to the IP I took advantage and asked together, I did not succeed in being able to find the IP and printer port

  • Isn’t your problem to do PHP code to use the printer? Is it that you don’t know how to look at the server where it is connected? There the problem is not of programming.

  • Tell me one thing the server is windows? Why if it is you could use COM, if it’s linux one exec(); would help.

Show 1 more comment

1 answer

1

I’ve had to solve a scenario near this.
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 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:

  1. 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;
  2. It is possible to send anything for printing as long as you have the correct driver 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.

Browser other questions tagged

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