I have deployed my Laravel App to AWS and using NGINX server. I want to print some receipts from server to the local printers. I am using this package mike42/escpos-php. and here is my code
try {
$connector = new \Mike42\Escpos\PrintConnectors\WindowsPrintConnector("POS-80C");
/* Print a "Hello world" receipt" */
$printer = new \Mike42\Escpos\Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
/* Close printer */
$printer -> close();
} catch (Exception $e) {
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}```
I have enabled sharing of this printer *POS-80C* from windows.
But whenever I try to print, I rceived this error.
Command "smbclient '//ip-172-31-43-229/POS-80C' -c 'print -' -N -m SMB2" failed with exit code 1: do_connect: Connection to ip-172-31-43-229 failed (Error NT_STATUS_CONNECTION_REFUSED)
Here *ip-172-31-43-229* is IP of server on AWS.
*smbclient* is working fine on nginx. What can be the issue?
What you are trying to achieve is very complicated, hard but possible.
exec("lpr -l -P $file $printer")orProcess::fromShellCommandline("lpr -l -P $file $printer"). No need for a particular composer package or pecl module.I have built two systems with Laravel on Ubuntu printing on a Windows shared printer using the procedure I described. It took me much time to find this solution. I would suggest implementing it in a smaller scale, meaning printing on another printer/PC in the same network, so you first solve the problems regarding remote printing. Then move to the final step where the server is on the cloud and the printer/PC on a local network. As I said you are trying to implement pretty advanced stuff.