diff --git a/README.md b/README.md index 17acf9f1..c5bb5c91 100644 --- a/README.md +++ b/README.md @@ -75,13 +75,16 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Bematech LR2000E - Birch PRP-085III - Bixolon SRP-350III +- Bixolon SRP-350Plus - Black Copper BC-85AC +- CHD TH-305N - Citizen CBM1000-II - Citizen CT-S310II - Dapper-Geyi Q583P - Daruma DR800 - DR-MP200 (manufacturer unknown) - EPOS TEP 220M +- Elgin i9 - Epson EU-T332C - Epson FX-890 (requires `feedForm()` to release paper). - Epson TM-T20 @@ -98,9 +101,11 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Epson TM-U295 (requires `release()` to release slip). - Epson TM-U590 and TM-U590P - Equal (EQ-IT-001) POS-58 +- Everycom EC-58 - Excelvan HOP-E200 - Excelvan HOP-E58 - Excelvan HOP-E801 +- Gainscha GP-2120TF - Gainscha GP-5890x (Also marketed as EC Line 5890x) - Gainscha GP-U80300I (Also marketed as gprinter GP-U80300I) - gprinter GP-U80160I @@ -122,9 +127,13 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Rongta RP326US - Rongta RP58-U - Rongta RP80USE +- SAM4S GIANT-100DB - Senor TP-100 - Sewoo SLK-TS400 +- SEYPOS PRP-96 - SEYPOS PRP-300 (Also marketed as TYSSO PRP-300) +- SNBC BTP-R880NPIII +- Solux SX-TP-88300 - Sicar POS-80 - Silicon SP-201 / RP80USE - SPRT SP-POS88V @@ -133,6 +142,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Star TSP100III FuturePRNT - Star TSP-650 - Star TUP-592 +- TVS RP45 Shoppe - Venus V248T - Xeumior SM-8330 - Xprinter F-900 @@ -146,6 +156,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Zjiang ZJ-5870 - Zjiang ZJ-5890 (Also sold as POS-5890 by many vendors; ZJ-5890K, ZJ-5890T also work). - Zjiang ZJ-8220 (Also marketed as Excelvan ZJ-8220) +- Zjiang ZJ-8250 If you use any other printer with this code, please [let us know](https://github.com/mike42/escpos-php/issues/new) so that it can be added to the list. diff --git a/example/README.md b/example/README.md index 68b0dc77..e59e6c09 100644 --- a/example/README.md +++ b/example/README.md @@ -23,4 +23,4 @@ Each example prints to standard output, so either edit the print connector, or r - `print-from-html.php` - Runs `wkhtmltoimage` to convert HTML to an image, and then prints the image. (This is very slow) - `character-tables.php` - Prints a compact character code table for each available character set. Used to debug incorrect output from `character-encodings.php`. - `print-from-pdf.php` - Loads a PDF and prints each page in a few different ways (very slow as well) - +- `rawbt-receipt` (.php & .html) - Demonstration of Back and Front for integration between the site and the Android application “RawBT - Printer Driver for Android” diff --git a/example/rawbt-receipt.html b/example/rawbt-receipt.html new file mode 100644 index 00000000..c3d307a9 --- /dev/null +++ b/example/rawbt-receipt.html @@ -0,0 +1,76 @@ + + + + + RawBT Integration Demo + + + + + + + +black & white picture +

RawBT Integration Demo

+
+
+    window.location.href = ajax_backend_data;
+
+
+
+ + +

Visit RawBT site

+ + diff --git a/example/rawbt-receipt.php b/example/rawbt-receipt.php new file mode 100644 index 00000000..45a4e8fc --- /dev/null +++ b/example/rawbt-receipt.php @@ -0,0 +1,145 @@ +getSupportsGraphics()) { + $printer->graphics($logo); + } + if ($profile->getSupportsBitImageRaster() && !$profile->getSupportsGraphics()) { + $printer->bitImage($logo); + } + + /* Name of shop */ + $printer->setJustification(Printer::JUSTIFY_CENTER); + $printer->selectPrintMode(Printer::MODE_DOUBLE_WIDTH); + $printer->text("ExampleMart Ltd.\n"); + $printer->selectPrintMode(); + $printer->text("Shop No. 42.\n"); + $printer->feed(); + + + /* Title of receipt */ + $printer->setEmphasis(true); + $printer->text("SALES INVOICE\n"); + $printer->setEmphasis(false); + + /* Items */ + $printer->setJustification(Printer::JUSTIFY_LEFT); + $printer->setEmphasis(true); + $printer->text(new item('', '$')); + $printer->setEmphasis(false); + foreach ($items as $item) { + $printer->text($item->getAsString(32)); // for 58mm Font A + } + $printer->setEmphasis(true); + $printer->text($subtotal->getAsString(32)); + $printer->setEmphasis(false); + $printer->feed(); + + /* Tax and total */ + $printer->text($tax->getAsString(32)); + $printer->selectPrintMode(Printer::MODE_DOUBLE_WIDTH); + $printer->text($total->getAsString(32)); + $printer->selectPrintMode(); + + /* Footer */ + $printer->feed(2); + $printer->setJustification(Printer::JUSTIFY_CENTER); + $printer->text("Thank you for shopping\n"); + $printer->text("at ExampleMart\n"); + $printer->text("For trading hours,\n"); + $printer->text("please visit example.com\n"); + $printer->feed(2); + $printer->text($date . "\n"); + + /* Barcode Default look */ + + $printer->barcode("ABC", Printer::BARCODE_CODE39); + $printer->feed(); + $printer->feed(); + + +// Demo that alignment QRcode is the same as text + $printer2 = new Printer($connector); // dirty printer profile hack !! + $printer2->setJustification(Printer::JUSTIFY_CENTER); + $printer2->qrCode("https://rawbt.ru/mike42", Printer::QR_ECLEVEL_M, 8); + $printer2->text("rawbt.ru/mike42\n"); + $printer2->setJustification(); + $printer2->feed(); + + + /* Cut the receipt and open the cash drawer */ + $printer->cut(); + $printer->pulse(); + +} catch (Exception $e) { + echo $e->getMessage(); +} finally { + $printer->close(); +} + +/* A wrapper to do organise item names & prices into columns */ + +class item +{ + private $name; + private $price; + private $dollarSign; + + public function __construct($name = '', $price = '', $dollarSign = false) + { + $this->name = $name; + $this->price = $price; + $this->dollarSign = $dollarSign; + } + + public function getAsString($width = 48) + { + $rightCols = 10; + $leftCols = $width - $rightCols; + if ($this->dollarSign) { + $leftCols = $leftCols / 2 - $rightCols / 2; + } + $left = str_pad($this->name, $leftCols); + + $sign = ($this->dollarSign ? '$ ' : ''); + $right = str_pad($sign . $this->price, $rightCols, ' ', STR_PAD_LEFT); + return "$left$right\n"; + } + + public function __toString() + { + return $this->getAsString(); + } + +} diff --git a/example/resources/rawbtlogo.png b/example/resources/rawbtlogo.png new file mode 100644 index 00000000..999abab3 Binary files /dev/null and b/example/resources/rawbtlogo.png differ diff --git a/src/Mike42/Escpos/PrintConnectors/RawbtPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/RawbtPrintConnector.php new file mode 100644 index 00000000..622f7263 --- /dev/null +++ b/src/Mike42/Escpos/PrintConnectors/RawbtPrintConnector.php @@ -0,0 +1,81 @@ +, + * incorporating modifications by others. See CONTRIBUTORS.md for a full list. + * + * This software is distributed under the terms of the MIT license. See LICENSE.md + * for details. + */ + +namespace Mike42\Escpos\PrintConnectors; + +/** + * Print connector for android RawBT application + * https://play.google.com/store/apps/details?id=ru.a402d.rawbtprinter + */ +final class RawbtPrintConnector implements PrintConnector +{ + /** + * @var array $buffer + * Buffer of accumilated data. + */ + private $buffer; + + /** + * @var string data which the printer will provide on next read + */ + private $readData; + + /** + * Create new print connector + */ + public function __construct() + { + ob_start(); + $this->buffer = []; + } + + public function clear() + { + $this->buffer = []; + } + + public function __destruct() + { + if ($this->buffer !== null) { + trigger_error("Print connector was not finalized. Did you forget to close the printer?", E_USER_NOTICE); + } + } + + public function finalize() + { + ob_end_clean(); + echo "intent:base64," . base64_encode($this->getData()) . "#Intent;scheme=rawbt;package=ru.a402d.rawbtprinter;end;"; + $this->buffer = null; + } + + /** + * @return string Get the accumulated data that has been sent to this buffer. + */ + public function getData() + { + return implode($this->buffer); + } + + /** + * {@inheritDoc} + * @see PrintConnector::read() + */ + public function read($len) + { + return $len >= strlen($this->readData) ? $this->readData : substr($this->readData, 0, $len); + } + + public function write($data) + { + $this->buffer[] = $data; + } +}