Laravel 5.8 Application Print to Local Thermal Printer

910 views Asked by At

I inherited a Laravel 5.8 Application that I need to add some features to. The first feature is a printing mechanism to print to a thermal printer (in this case, the MUNBYN Receipt Printer, Thermal Receipt Printer Works with Windows Mac Chromebook Linux Cash Drawer, USB/Ethernet Port 80mm Printer for POS, High-Speed Auto-Cutter Wall Mount, ESC/POS, ITPP047).

I am familiar with the following package: https://github.com/mike42/escpos-php

I've also been able to use my dev env's Windows 11 utility: net use LPT1... and was able to send a test print to the printer.

What is going to be the easiest way to send a receipt that I build within the Laravel application to a local thermal printer ... or any printer for that matter? I realize that printing from the cloud to a local network device is not trivial, but this has been a question asked in the past a few times and there still seem to be no solutions.

Thanks for your help in advance.

Thanks, Ron

I configured the following package: https://github.com/mike42/escpos-php and tested to no avail.

Route::get('/', function () {
    $connector = new NetworkPrintConnector("169.254.191.48", 9100);
    $printer = new Printer($connector);
    try {
        $printer -> text("Hello World");
    //} finally {
        $printer -> close();
    } catch(Exception $e) {
        echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
    }
});

I've also been able to use my dev env's Windows 11 utility: net use LPT1... and was able to send a test print to the printer using basic echo statements. The Laravel route code test will not send. The connection times out. I read some articles saying perhaps it's the permissions on the local network and device.

0

There are 0 answers