<?php /* Change to the correct path if you copy this example! */ require __DIR__ . '/../../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\CupsPrintConnector; try { $connector = new CupsPrintConnector("EPSON_TM-T20"); /* Print a "Hello world" receipt" */ $printer = new 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"; }
* Most printers implement only a subset of the functionality of the driver, so * will not render this output correctly in all cases. * * @author Michael Billington <*****@*****.**> */ require __DIR__ . '/../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintConnector; use Mike42\Escpos\EscposImage; $connector = new FilePrintConnector("php://stdout"); $printer = new Printer($connector); /* Initialize */ $printer->initialize(); /* Text */ $printer->text("Hello world\n"); $printer->cut(); /* Line feeds */ $printer->text("ABC"); $printer->feed(7); $printer->text("DEF"); $printer->feedReverse(3); $printer->text("GHI"); $printer->feed(); $printer->cut(); /* Font modes */ $modes = array(Printer::MODE_FONT_B, Printer::MODE_EMPHASIZED, Printer::MODE_DOUBLE_HEIGHT, Printer::MODE_DOUBLE_WIDTH, Printer::MODE_UNDERLINE); for ($i = 0; $i < pow(2, count($modes)); $i++) { $bits = str_pad(decbin($i), count($modes), "0", STR_PAD_LEFT); $mode = 0; for ($j = 0; $j < strlen($bits); $j++) { if (substr($bits, $j, 1) == "1") {