Search code examples
laravelwebprintingepsonpos

Print Bill from POS Printer on Web Base PHP laravel application


I have developed web based POS system. Then I hosted that in cpanel server. I can print the bill in localhost but not in live server. I used ESC/POS Print Driver for that. Can you help me solve this Problem?

<?php
 public function test() {
    try {
        $connector = new WindowsPrintConnector("POS Printer");
        $printer = new Printer($connector);
        $printer->text("Hello World!");
        $printer->cut();
         $printer->close();
    } catch (Exception $e) {
        echo "Couldn't print to this printer: " . $e->getMessage();
    }
}

?>


Solution

  • The first question is, what are you trying to achive?

    1. Are you trying to print to the server's printer? - I noticed in your code, the package you're using, your server must have a direct connection to a printer. Which currently doesn't have a connection to any printer.

    2. Are you trying to print to the user's printer? - If you just want to print to the user's printer, just render a normal HTML (or render it to a PDF since you want to print a bill) then print that document on your browser.