diff --git a/README.md b/README.md index 7f5ac2dd..17acf9f1 100644 --- a/README.md +++ b/README.md @@ -67,11 +67,13 @@ This driver is known to work with the following OS/interface combinations: ### Printers Many thermal receipt printers support ESC/POS to some degree. This driver has been known to work with: -- 3nStrat POS-08 +- 3nStar RPT-008 +- Approx APPPOS80AM - AURES ODP-333 - AURES ODP-500 - Bematech-4200-TH - Bematech LR2000E +- Birch PRP-085III - Bixolon SRP-350III - Black Copper BC-85AC - Citizen CBM1000-II @@ -99,23 +101,29 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Excelvan HOP-E200 - Excelvan HOP-E58 - Excelvan HOP-E801 -- Excelvan ZJ-8220 - Gainscha GP-5890x (Also marketed as EC Line 5890x) - Gainscha GP-U80300I (Also marketed as gprinter GP-U80300I) - gprinter GP-U80160I +- HOIN HOP-H58 +- Ithaca iTherm 28 - Hasar HTP 250 - Metapace T-1 - Metapace T-25 - Nexa PX700 - Nyear NP100 -- Okipos 80 Plus III +- OKI RT322 +- OKI 80 Plus III - Orient BTP-R580 -- Partner Tech RP320 - P-822D - P85A-401 (make unknown) +- Partner Tech RP320 +- POSLIGNE ODP200H-III-G +- QPOS Q58M - Rongta RP326US - Rongta RP58-U +- Rongta RP80USE - Senor TP-100 +- Sewoo SLK-TS400 - SEYPOS PRP-300 (Also marketed as TYSSO PRP-300) - Sicar POS-80 - Silicon SP-201 / RP80USE @@ -126,6 +134,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Star TSP-650 - Star TUP-592 - Venus V248T +- Xeumior SM-8330 - Xprinter F-900 - Xprinter XP-365B - Xprinter XP-58 Series @@ -135,9 +144,8 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Xprinter XP-Q800 - Zjiang NT-58H - Zjiang ZJ-5870 -- Zjiang ZJ-5890K -- Zjiang ZJ-5890T (Marketed as POS 5890T) -- Zjiang ZJ-8220 +- 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) 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/character-encodings-with-images.php b/example/character-encodings-with-images.php index f14d73a7..bc99c2f1 100644 --- a/example/character-encodings-with-images.php +++ b/example/character-encodings-with-images.php @@ -3,9 +3,9 @@ require __DIR__ . '/../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintConnector; -use Mike42\Escpos\CapabilityProfiles\DefaultCapabilityProfile; use Mike42\Escpos\PrintBuffers\EscposPrintBuffer; use Mike42\Escpos\PrintBuffers\ImagePrintBuffer; +use Mike42\Escpos\CapabilityProfile; /** * This example builds on character-encodings.php, also providing an image-based rendering. @@ -21,7 +21,7 @@ try { // Enter connector and capability profile $connector = new FilePrintConnector("php://stdout"); - $profile = DefaultCapabilityProfile::getInstance(); + $profile = CapabilityProfile::load('default'); $buffers = array(new EscposPrintBuffer(), new ImagePrintBuffer()); /* Print a series of receipts containing i18n example strings */ diff --git a/example/character-encodings.php b/example/character-encodings.php index 4da80187..a38e99fb 100644 --- a/example/character-encodings.php +++ b/example/character-encodings.php @@ -3,7 +3,7 @@ require __DIR__ . '/../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintConnector; -use Mike42\Escpos\CapabilityProfiles\DefaultCapabilityProfile; +use Mike42\Escpos\CapabilityProfile; /** * This demonstrates available character encodings. Escpos-php accepts UTF-8, @@ -27,7 +27,7 @@ try { // Enter connector and capability profile (to match your printer) $connector = new FilePrintConnector("php://stdout"); - $profile = DefaultCapabilityProfile::getInstance(); + $profile = CapabilityProfile::load("default"); /* Print a series of receipts containing i18n example strings */ $printer = new Printer($connector, $profile); diff --git a/example/character-tables.php b/example/character-tables.php index 7174515d..d2ab8bbc 100644 --- a/example/character-tables.php +++ b/example/character-tables.php @@ -17,11 +17,11 @@ require __DIR__ . '/../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintConnector; -use Mike42\Escpos\CapabilityProfiles\DefaultCapabilityProfile; +use Mike42\Escpos\CapabilityProfile; // Enter connector and capability profile (to match your printer) $connector = new FilePrintConnector("php://stdout"); -$profile = DefaultCapabilityProfile::getInstance(); +$profile = CapabilityProfile::load("default"); $verbose = false; // Skip tables which iconv wont convert to (ie, only print characters available with UTF-8 input) /* Print a series of receipts containing i18n example strings - Code below shouldn't need changing */ diff --git a/example/specific/32-german-tm-t20-ii-custom-command.php b/example/specific/32-german-tm-t20-ii-custom-command.php index a5bcc5b8..29b6b3fc 100644 --- a/example/specific/32-german-tm-t20-ii-custom-command.php +++ b/example/specific/32-german-tm-t20-ii-custom-command.php @@ -1,8 +1,8 @@ text("El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro.\n"); $printer -> cut(); diff --git a/example/specific/37-chinese.php b/example/specific/37-chinese.php index 5ac2d0bf..d14790f4 100644 --- a/example/specific/37-chinese.php +++ b/example/specific/37-chinese.php @@ -7,12 +7,12 @@ * can be properly detected and printed alongside other encodings. */ require __DIR__ . '/../../autoload.php'; +use Mike42\Escpos\CapabilityProfile; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintConnector; -use Mike42\Escpos\CapabilityProfiles\SimpleCapabilityProfile; $connector = new FilePrintConnector("/dev/usb/lp1"); -$profile = SimpleCapabilityProfile::getInstance(); +$profile = CapabilityProfile::load("default"); $printer = new Printer($connector); diff --git a/example/specific/39-currency-symbols.php b/example/specific/39-currency-symbols.php index acd384c3..b960ee68 100644 --- a/example/specific/39-currency-symbols.php +++ b/example/specific/39-currency-symbols.php @@ -1,12 +1,11 @@ setFont($fontPath); $buffer -> setFontSize($fontSize); -$profile = EposTepCapabilityProfile::getInstance(); +$profile = CapabilityProfile::load("TEP-200M"); $connector = new FilePrintConnector("php://output"); // = new WindowsPrintConnector("LPT2"); // Windows LPT2 was used in the bug tracker diff --git a/example/specific/62-greek-symbol-swap.php b/example/specific/62-greek-symbol-swap.php index 9aaf937f..5ea995e5 100644 --- a/example/specific/62-greek-symbol-swap.php +++ b/example/specific/62-greek-symbol-swap.php @@ -2,10 +2,10 @@ require __DIR__ . '/../../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintConnector; -use Mike42\Escpos\CapabilityProfiles\DefaultCapabilityProfile; +use Mike42\Escpos\CapabilityProfile; $connector = new FilePrintConnector("php://stdout"); -$profile = DefaultCapabilityProfile::getInstance(); +$profile = CapabilityProfile::load("default"); $printer = new Printer($connector, $profile); $printer -> text("Μιχάλης Νίκος\n"); diff --git a/example/specific/68-redblack.php b/example/specific/68-redblack.php index becc6252..142a83ab 100644 --- a/example/specific/68-redblack.php +++ b/example/specific/68-redblack.php @@ -10,9 +10,9 @@ $printer = new Printer($connector); try { $printer -> text("Hello World!\n"); - $printer -> setColor(Escpos::COLOR_2); + $printer -> setColor(Printer::COLOR_2); $printer -> text("Red?!\n"); - $printer -> setColor(Escpos::COLOR_1); + $printer -> setColor(Printer::COLOR_1); $printer -> text("Default color again?!\n"); $printer -> cut(); } finally { diff --git a/src/Mike42/Escpos/CapabilityProfile.php b/src/Mike42/Escpos/CapabilityProfile.php index 25695a49..9a913905 100644 --- a/src/Mike42/Escpos/CapabilityProfile.php +++ b/src/Mike42/Escpos/CapabilityProfile.php @@ -3,15 +3,15 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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; -use Mike42\Escpos\CodePage; use \InvalidArgumentException; /** @@ -108,7 +108,7 @@ class CapabilityProfile * Construct new CapabilityProfile. * The encoding data must be loaded from disk before calling. * - * @param unknown $profileId + * @param string $profileId * ID of the profile * @param array $profileData * Profile data from disk. diff --git a/src/Mike42/Escpos/CodePage.php b/src/Mike42/Escpos/CodePage.php index 9eb846d9..25f58b95 100644 --- a/src/Mike42/Escpos/CodePage.php +++ b/src/Mike42/Escpos/CodePage.php @@ -3,12 +3,13 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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; use \InvalidArgumentException; diff --git a/src/Mike42/Escpos/Devices/AuresCustomerDisplay.php b/src/Mike42/Escpos/Devices/AuresCustomerDisplay.php index 5dbdb47e..3bf9101a 100644 --- a/src/Mike42/Escpos/Devices/AuresCustomerDisplay.php +++ b/src/Mike42/Escpos/Devices/AuresCustomerDisplay.php @@ -1,4 +1,15 @@ , + * 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\Devices; use Mike42\Escpos\Printer; diff --git a/src/Mike42/Escpos/EscposImage.php b/src/Mike42/Escpos/EscposImage.php index 20da9c8a..9a625acb 100644 --- a/src/Mike42/Escpos/EscposImage.php +++ b/src/Mike42/Escpos/EscposImage.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 @@ -56,13 +56,13 @@ abstract class EscposImage private $imgData = null; /** - * @var string $imgColumnData + * @var array:string $imgColumnData * Cached column-format data to avoid re-computation */ private $imgColumnData = []; /** - * @var array:string $imgRasterData + * @var string $imgRasterData * Cached raster format data to avoid re-computation */ private $imgRasterData = null; @@ -164,32 +164,33 @@ public function toRasterFormat() */ public function toColumnFormat($doubleDensity = false) { + $densityIdx = $doubleDensity ? 1 : 0; // Just wraps implementations for caching and lazy loading - if (isset($this -> imgColumnData[$doubleDensity])) { + if (isset($this -> imgColumnData[$densityIdx])) { /* Return cached value */ - return $this -> imgColumnData[$doubleDensity]; + return $this -> imgColumnData[$densityIdx]; } - $this -> imgColumnData[$doubleDensity] = null; + $this -> imgColumnData[$densityIdx] = null; if ($this -> allowOptimisations) { /* Use optimised code if allowed */ $data = $this -> getColumnFormatFromFile($this -> filename, $doubleDensity); - $this -> imgColumnData[$doubleDensity] = $data; + $this -> imgColumnData[$densityIdx] = $data; } - if ($this -> imgColumnData[$doubleDensity] === null) { + if ($this -> imgColumnData[$densityIdx] === null) { /* Load in full image and render the slow way if no faster implementation is available, or if we've been asked not to use it */ if ($this -> imgData === null) { $this -> loadImageData($this -> filename); } - $this -> imgColumnData[$doubleDensity] = $this -> getColumnFormat($doubleDensity); + $this -> imgColumnData[$densityIdx] = $this -> getColumnFormat($doubleDensity); } - return $this -> imgColumnData[$doubleDensity]; + return $this -> imgColumnData[$densityIdx]; } /** * Load an image from disk. This default implementation always gives a zero-sized image. * - * @param string $filename Filename to load from. + * @param string|null $filename Filename to load from. */ protected function loadImageData($filename = null) { @@ -325,9 +326,9 @@ private function getColumnFormat($highDensity) /** * Output image in column format. Must be called once for each line of output. * - * @param string $lineNo + * @param int $lineNo * Line number to retrieve - * @param string $highDensity + * @param bool $highDensity * True for high density output (24px lines), false for regular density (8px) * @throws Exception * Where wrong number of bytes has been generated. @@ -407,7 +408,7 @@ public static function isImagickLoaded() * * @param string $filename * File to load from - * @param string $allow_optimisations + * @param bool $allowOptimisations * True to allow the fastest rendering shortcuts, false to force the library * to read the image into an internal raster format and use PHP to render * the image (slower but less fragile). @@ -421,7 +422,7 @@ public static function isImagickLoaded() */ public static function load( $filename, - $allow_optimisations = true, + $allowOptimisations = true, array $preferred = ['imagick', 'gd', 'native'] ) { /* Fail early if file is not readble */ @@ -436,19 +437,19 @@ public static function load( // Skip option if Imagick is not loaded continue; } - return new \Mike42\Escpos\ImagickEscposImage($filename, $allow_optimisations); + return new \Mike42\Escpos\ImagickEscposImage($filename, $allowOptimisations); } elseif ($implemetnation === 'gd') { if (!self::isGdLoaded()) { // Skip option if GD not loaded continue; } - return new \Mike42\Escpos\GdEscposImage($filename, $allow_optimisations); + return new \Mike42\Escpos\GdEscposImage($filename, $allowOptimisations); } elseif ($implemetnation === 'native') { if (!in_array($ext, ['wbmp', 'pbm', 'bmp'])) { // Pure PHP is fastest way to generate raster output from wbmp and pbm formats. continue; } - return new \Mike42\Escpos\NativeEscposImage($filename, $allow_optimisations); + return new \Mike42\Escpos\NativeEscposImage($filename, $allowOptimisations); } else { // Something else on the 'preferred' list. throw new InvalidArgumentException("'$implemetnation' is not a known EscposImage implementation"); diff --git a/src/Mike42/Escpos/GdEscposImage.php b/src/Mike42/Escpos/GdEscposImage.php index 12040c71..32edf76e 100644 --- a/src/Mike42/Escpos/GdEscposImage.php +++ b/src/Mike42/Escpos/GdEscposImage.php @@ -23,7 +23,7 @@ class GdEscposImage extends EscposImage /** * Load an image from disk, into memory, using GD. * - * @param string $filename The filename to load from + * @param string|null $filename The filename to load from * @throws Exception if the image format is not supported, * or the file cannot be opened. */ diff --git a/src/Mike42/Escpos/ImagickEscposImage.php b/src/Mike42/Escpos/ImagickEscposImage.php index 49cec670..13851a4d 100644 --- a/src/Mike42/Escpos/ImagickEscposImage.php +++ b/src/Mike42/Escpos/ImagickEscposImage.php @@ -3,12 +3,13 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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; use Exception; @@ -84,7 +85,7 @@ protected function getColumnFormatFromFile($filename = null, $highDensityVertica /** * Load an image from disk, into memory, using Imagick. * - * @param string $filename The filename to load from + * @param string|null $filename The filename to load from * @throws Exception if the image format is not supported, * or the file cannot be opened. */ @@ -150,7 +151,7 @@ private function getImageFromFile($filename) try { $im->setResourceLimit(6, 1); // Prevent libgomp1 segfaults, grumble grumble. $im -> readimage($filename); - } catch (ImagickException $e) { + } catch (\ImagickException $e) { /* Re-throw as normal exception */ throw new Exception($e); } @@ -204,12 +205,12 @@ protected function getRasterFormatFromFile($filename = null) * * @param string $pdfFile * The file to load - * @param string $pageWidth + * @param int $pageWidth * The width, in pixels, of the printer's output. The first page of the * PDF will be scaled to approximately fit in this area. * @throws Exception Where Imagick is not loaded, or where a missing file * or invalid page number is requested. - * @return multitype:EscposImage Array of images, retrieved from the PDF file. + * @return array Array of images, retrieved from the PDF file. */ public static function loadPdf($pdfFile, $pageWidth = 550) { diff --git a/src/Mike42/Escpos/NativeEscposImage.php b/src/Mike42/Escpos/NativeEscposImage.php index 34ef7fe6..e85c942b 100644 --- a/src/Mike42/Escpos/NativeEscposImage.php +++ b/src/Mike42/Escpos/NativeEscposImage.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 diff --git a/src/Mike42/Escpos/PrintBuffers/EscposPrintBuffer.php b/src/Mike42/Escpos/PrintBuffers/EscposPrintBuffer.php index 30bf50e3..4e041765 100644 --- a/src/Mike42/Escpos/PrintBuffers/EscposPrintBuffer.php +++ b/src/Mike42/Escpos/PrintBuffers/EscposPrintBuffer.php @@ -50,7 +50,7 @@ class EscposPrintBuffer implements PrintBuffer private $encode = null; /** - * @var Printer $printer + * @var Printer|null $printer * Printer for output */ private $printer; diff --git a/src/Mike42/Escpos/PrintBuffers/ImagePrintBuffer.php b/src/Mike42/Escpos/PrintBuffers/ImagePrintBuffer.php index e18d4c1c..d4fdefaf 100644 --- a/src/Mike42/Escpos/PrintBuffers/ImagePrintBuffer.php +++ b/src/Mike42/Escpos/PrintBuffers/ImagePrintBuffer.php @@ -27,6 +27,9 @@ class ImagePrintBuffer implements PrintBuffer { private $printer; + /** + * @var string|null font to use + */ private $font; private $fontSize; @@ -104,7 +107,7 @@ public function writeTextRaw($text) if ($this -> printer == null) { throw new LogicException("Not attached to a printer."); } - $this -> printer -> getPrintConnector() -> write($data); + $this -> printer -> getPrintConnector() -> write($text); } /** diff --git a/src/Mike42/Escpos/PrintBuffers/PrintBuffer.php b/src/Mike42/Escpos/PrintBuffers/PrintBuffer.php index c5e84e2a..fcad6e9e 100644 --- a/src/Mike42/Escpos/PrintBuffers/PrintBuffer.php +++ b/src/Mike42/Escpos/PrintBuffers/PrintBuffer.php @@ -43,7 +43,7 @@ public function getPrinter(); /** * Used by Escpos to hook up one-to-one link between buffers and printers. * - * @param Escpos $printer New printer + * @param Printer|null $printer New printer */ public function setPrinter(Printer $printer = null); diff --git a/src/Mike42/Escpos/PrintConnectors/CupsPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/CupsPrintConnector.php index 29f692b5..497887f3 100644 --- a/src/Mike42/Escpos/PrintConnectors/CupsPrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/CupsPrintConnector.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 diff --git a/src/Mike42/Escpos/PrintConnectors/DummyPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/DummyPrintConnector.php index fffebce5..b376cd87 100644 --- a/src/Mike42/Escpos/PrintConnectors/DummyPrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/DummyPrintConnector.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 diff --git a/src/Mike42/Escpos/PrintConnectors/FilePrintConnector.php b/src/Mike42/Escpos/PrintConnectors/FilePrintConnector.php index 014aa6fe..ca44ad0a 100644 --- a/src/Mike42/Escpos/PrintConnectors/FilePrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/FilePrintConnector.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 diff --git a/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php index 46e0956a..10aa6640 100644 --- a/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/NetworkPrintConnector.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 diff --git a/src/Mike42/Escpos/PrintConnectors/PrintConnector.php b/src/Mike42/Escpos/PrintConnectors/PrintConnector.php index 0b18d03e..4198dbc1 100644 --- a/src/Mike42/Escpos/PrintConnectors/PrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/PrintConnector.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 diff --git a/src/Mike42/Escpos/PrintConnectors/UriPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/UriPrintConnector.php index 88d5dc56..c51d2bf3 100644 --- a/src/Mike42/Escpos/PrintConnectors/UriPrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/UriPrintConnector.php @@ -5,13 +5,15 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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; + class UriPrintConnector { const URI_ASSEMBLER_PATTERN = "~^(.+):/{2}(.+?)(?::(\d{1,4}))?$~"; diff --git a/src/Mike42/Escpos/PrintConnectors/WindowsPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/WindowsPrintConnector.php index 4266730e..9bab87cd 100644 --- a/src/Mike42/Escpos/PrintConnectors/WindowsPrintConnector.php +++ b/src/Mike42/Escpos/PrintConnectors/WindowsPrintConnector.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 @@ -100,7 +100,7 @@ class WindowsPrintConnector implements PrintConnector /** * Valid smb:// URI containing hostname & printer with optional user & optional password only. */ - const REGEX_SMB = "/^smb:\/\/([\s\d\w-]+(:[\s\d\w-+]+)?@)?([\d\w-]+\.)*[\d\w-]+\/([\d\w-]+\/)?[\d\w-]+(\s[\d\w-]+)*$/"; + const REGEX_SMB = "/^smb:\/\/([\s\d\w-]+(:[\s\d\w+-]+)?@)?([\d\w-]+\.)*[\d\w-]+\/([\d\w-]+\/)?[\d\w-]+(\s[\d\w-]+)*$/"; /** * @param string $dest diff --git a/src/Mike42/Escpos/Printer.php b/src/Mike42/Escpos/Printer.php index 5e732b1a..753d2ea8 100644 --- a/src/Mike42/Escpos/Printer.php +++ b/src/Mike42/Escpos/Printer.php @@ -3,7 +3,7 @@ * This file is part of escpos-php: PHP receipt printer library for use with * ESC/POS-compatible thermal and impact printers. * - * Copyright (c) 2014-16 Michael Billington < michael.billington@gmail.com >, + * Copyright (c) 2014-18 Michael Billington < michael.billington@gmail.com >, * 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 @@ -328,7 +328,7 @@ class Printer const UNDERLINE_DOUBLE = 2; /** - * @var PrintBuffer $buffer + * @var PrintBuffer|null $buffer * The printer's output buffer. */ protected $buffer; @@ -355,7 +355,7 @@ class Printer * Construct a new print object * * @param PrintConnector $connector The PrintConnector to send data to. If not set, output is sent to standard output. - * @param CapabilityProfile $profile Supported features of this printer. If not set, the "default" CapabilityProfile will be used, which is suitable for Epson printers. + * @param CapabilityProfile|null $profile Supported features of this printer. If not set, the "default" CapabilityProfile will be used, which is suitable for Epson printers. * @throws InvalidArgumentException */ public function __construct(PrintConnector $connector, CapabilityProfile $profile = null) @@ -636,15 +636,15 @@ public function initialize() * Print a two-dimensional data code using the PDF417 standard. * * @param string $content Text or numbers to store in the code - * @param number $width Width of a module (pixel) in the printed code. + * @param int $width Width of a module (pixel) in the printed code. * Default is 3 dots. - * @param number $heightMultiplier Multiplier for height of a module. + * @param int $heightMultiplier Multiplier for height of a module. * Default is 3 times the width. - * @param number $dataColumnCount Number of data columns to use. 0 (default) + * @param int $dataColumnCount Number of data columns to use. 0 (default) * is to auto-calculate. Smaller numbers will result in a narrower code, * making larger pixel sizes possible. Larger numbers require smaller pixel sizes. - * @param real $ec Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%). - * @param number $options Standard code Printer::PDF417_STANDARD with + * @param float $ec Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%). + * @param int $options Standard code Printer::PDF417_STANDARD with * start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only. * @throws Exception If this profile indicates that PDF417 code is not supported */ @@ -869,7 +869,7 @@ public function setJustification($justification = Printer::JUSTIFY_LEFT) * * Some printers will allow you to overlap lines with a smaller line feed. * - * @param int $height The height of each line, in dots. If not set, the printer + * @param int|null $height The height of each line, in dots. If not set, the printer * will reset to its default line spacing. */ public function setLineSpacing($height = null) @@ -972,7 +972,18 @@ public function setUnderline($underline = Printer::UNDERLINE_SINGLE) self::validateInteger($underline, 0, 2, __FUNCTION__); $this -> connector -> write(self::ESC . "-" . chr($underline)); } - + + /** + * Print each line upside-down (180 degrees rotated). + * + * @param boolean $on True to enable, false to disable. + */ + public function setUpsideDown($on = true) + { + self::validateBoolean($on, __FUNCTION__); + $this -> connector -> write(self::ESC . "{" . ($on ? chr(1) : chr(0))); + } + /** * Add text to the buffer. * diff --git a/src/Mike42/Escpos/resources/capabilities.json b/src/Mike42/Escpos/resources/capabilities.json index 6edc7d56..c60cac0d 100644 --- a/src/Mike42/Escpos/resources/capabilities.json +++ b/src/Mike42/Escpos/resources/capabilities.json @@ -250,6 +250,19 @@ "name": "ISO_8859-7", "python_encode": "iso8859_7" }, + "OXHOO-EUROPEAN": { + "data": [ + "\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5", + "\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f1\u00d1\u00aa\u00ba\u00bf", + "\u00e1\u00ed\u00f3\u00fa\u00a2\u00a3\u00a5\u20a7\u0192\u00a1\u00c3\u00e3\u00d5\u00f5\u00d8\u00f8", + "\u00b7\u00a8\u00b0`\u00b4\u00bd\u00bc\u00d7\u00f7\u2264\u2265\u00ab\u00bb\u2260\u221a\u00af", + "\u2320\u2321\u221e\u25e4\u21b5\u2191\u2193\u2192\u2190\u250c\u2510\u2514\u2518\u2022\u00ae\u00a9", + "\u2122\u2020\u00a7\u00b6\u0393\u25e2\u0398 ", + "\u00df \u03b5 ", + "\u03c4 " + ], + "name": "Oxhoo-specific European" + }, "RK1048": { "iconv": "RK1048", "name": "RK1048" @@ -286,6 +299,44 @@ } }, "profiles": { + "AF-240": { + "codePages": { + "0": "OXHOO-EUROPEAN" + }, + "colors": { + "0": "black" + }, + "features": { + "barcodeA": false, + "barcodeB": false, + "bitImageColumn": false, + "bitImageRaster": false, + "graphics": false, + "highDensity": false, + "paperFullCut": false, + "paperPartCut": false, + "pdf417Code": false, + "pulseBel": false, + "pulseStandard": false, + "qrCode": false, + "starCommands": false + }, + "fonts": { + "0": { + "columns": 20, + "name": "Font A" + } + }, + "media": { + "width": { + "mm": 120, + "pixels": 100 + } + }, + "name": "AF-240 Customer Display", + "notes": "This is a two-line, ESC/POS-aware customer display from Oxhoo. The ESC/POS command mode can be activated persistently by sending:\n\n echo -ne \"\\n\\x02\\x05\\x43\\x31\\x03\" > /dev/ttyUSB0\n", + "vendor": "Oxhoo" + }, "NT-5890K": { "codePages": { "0": "CP437", @@ -395,6 +446,62 @@ "notes": "", "vendor": "Netum" }, + "OCD-100": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "Unknown", + "7": "Unknown", + "8": "Unknown", + "9": "CP852", + "10": "CP862", + "11": "CP866", + "12": "CP1251", + "13": "CP1254", + "14": "CP1255", + "15": "CP1257", + "16": "CP1252", + "17": "CP1253", + "19": "CP858" + }, + "colors": { + "0": "black" + }, + "features": { + "barcodeA": false, + "barcodeB": false, + "bitImageColumn": false, + "bitImageRaster": false, + "graphics": false, + "highDensity": false, + "paperFullCut": false, + "paperPartCut": false, + "pdf417Code": false, + "pulseBel": false, + "pulseStandard": false, + "qrCode": false, + "starCommands": false + }, + "fonts": { + "0": { + "columns": 20, + "name": "Font A" + } + }, + "media": { + "width": { + "mm": 180, + "pixels": 100 + } + }, + "name": "OCD-100 Customer Display", + "notes": "This is a two-line, ESC/POS-aware customer display from Aures. It has some graphics support via custom fonts, but is otherwise text-only. This profile is also suitable for the OCD-150 pole-mounted display.\n", + "vendor": "Aures" + }, "OCD-300": { "codePages": { "0": "CP437", @@ -428,12 +535,12 @@ "bitImageColumn": false, "bitImageRaster": false, "graphics": false, - "highDensity": true, + "highDensity": false, "paperFullCut": false, "paperPartCut": false, "pdf417Code": false, "pulseBel": false, - "pulseStandard": true, + "pulseStandard": false, "qrCode": false, "starCommands": false }, @@ -445,11 +552,11 @@ }, "media": { "width": { - "mm": "Unknown", - "pixels": "Unknown" + "mm": 130.2, + "pixels": 240 } }, - "name": "Aures OCP-300 Customer Display", + "name": "OCD-300 Customer Display", "notes": "This is a two-line, ESC/POS-aware customer display from Aures. It has some graphics support via vendor-provided tools, but is otherwise text-only.\n", "vendor": "Aures" }, diff --git a/test/unit/EscposTest.php b/test/unit/EscposTest.php index 5ac5f263..0b70e96b 100644 --- a/test/unit/EscposTest.php +++ b/test/unit/EscposTest.php @@ -1100,6 +1100,13 @@ public function testPrintLeftMarginInvalid() $this -> printer -> setPrintLeftMargin(70000); $this -> checkOutput(); } + + /* Upside-down print */ + public function testSetUpsideDown() + { + $this -> printer -> setUpsideDown(true); + $this -> checkOutput("\x1b@\x1b{\x01"); + } } /*