diff --git a/htdocs/includes/mike42/escpos-php/example/README.md b/htdocs/includes/mike42/escpos-php/example/README.md deleted file mode 100644 index e59e6c095e4..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Examples --------- - -This folder contains a collectoion of feature examples. -Generally, demo.php is the fastest way to find out which features your -printer supports. - -## Subfolders -- `interface/` - contains examples for output interfaces: eg, parallel, serial, USB, network, file-based. -- `specific/` - examples made in response to issues & questions. These cover specific languages, printers and interfaces, so hit narrower use cases. - -## List of examples - -Each example prints to standard output, so either edit the print connector, or redirect the output to your printer to see it in action. They are designed for developers: open them in a text editor before you run them! - -- `bit-image.php` - Prints a images to the printer using the older "bit image" commands. -- `demo.php` - Demonstrates output using a large subset of availale features. -- `qr-code.php` - Prints QR codes, if your printer supports it. -- `character-encodings.php` - Shows available character encodings. Change from the DefaultCapabilityProfile to get more useful output for your specific printer. -- `graphics.php` - The same output as `bit-image.php`, printed with the newer graphics commands (not supported on many non-Epson printers) -- `receipt-with-logo.php` - A simple receipt containing a logo and basic formating. -- `character-encodings-with-images.php` - The same as `character-encodings.php`, but also prints each string using an `ImagePrintBuffer`, showing compatibility gaps. -- `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/htdocs/includes/mike42/escpos-php/example/barcode.php b/htdocs/includes/mike42/escpos-php/example/barcode.php deleted file mode 100644 index d3ef9f2f44a..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/barcode.php +++ /dev/null @@ -1,207 +0,0 @@ -selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH); -$printer->text("Height and bar width\n"); -$printer->selectPrintMode(); -$heights = array(1, 2, 4, 8, 16, 32); -$widths = array(1, 2, 3, 4, 5, 6, 7, 8); -$printer -> text("Default look\n"); -$printer->barcode("ABC", Printer::BARCODE_CODE39); - -foreach($heights as $height) { - $printer -> text("\nHeight $height\n"); - $printer->setBarcodeHeight($height); - $printer->barcode("ABC", Printer::BARCODE_CODE39); -} -foreach($widths as $width) { - $printer -> text("\nWidth $width\n"); - $printer->setBarcodeWidth($width); - $printer->barcode("ABC", Printer::BARCODE_CODE39); -} -$printer->feed(); -// Set to something sensible for the rest of the examples -$printer->setBarcodeHeight(40); -$printer->setBarcodeWidth(2); - -/* Text position */ -$printer->selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH); -$printer->text("Text position\n"); -$printer->selectPrintMode(); -$hri = array ( - Printer::BARCODE_TEXT_NONE => "No text", - Printer::BARCODE_TEXT_ABOVE => "Above", - Printer::BARCODE_TEXT_BELOW => "Below", - Printer::BARCODE_TEXT_ABOVE | Printer::BARCODE_TEXT_BELOW => "Both" -); -foreach ($hri as $position => $caption) { - $printer->text($caption . "\n"); - $printer->setBarcodeTextPosition($position); - $printer->barcode("012345678901", Printer::BARCODE_JAN13); - $printer->feed(); -} - -/* Barcode types */ -$standards = array ( - Printer::BARCODE_UPCA => array ( - "title" => "UPC-A", - "caption" => "Fixed-length numeric product barcodes.", - "example" => array ( - array ( - "caption" => "12 char numeric including (wrong) check digit.", - "content" => "012345678901" - ), - array ( - "caption" => "Send 11 chars to add check digit automatically.", - "content" => "01234567890" - ) - ) - ), - Printer::BARCODE_UPCE => array ( - "title" => "UPC-E", - "caption" => "Fixed-length numeric compact product barcodes.", - "example" => array ( - array ( - "caption" => "6 char numeric - auto check digit & NSC", - "content" => "123456" - ), - array ( - "caption" => "7 char numeric - auto check digit", - "content" => "0123456" - ), - array ( - "caption" => "8 char numeric", - "content" => "01234567" - ), - array ( - "caption" => "11 char numeric - auto check digit", - "content" => "01234567890" - ), - array ( - "caption" => "12 char numeric including (wrong) check digit", - "content" => "012345678901" - ) - ) - ), - Printer::BARCODE_JAN13 => array ( - "title" => "JAN13/EAN13", - "caption" => "Fixed-length numeric barcodes.", - "example" => array ( - array ( - "caption" => "12 char numeric - auto check digit", - "content" => "012345678901" - ), - array ( - "caption" => "13 char numeric including (wrong) check digit", - "content" => "0123456789012" - ) - ) - ), - Printer::BARCODE_JAN8 => array ( - "title" => "JAN8/EAN8", - "caption" => "Fixed-length numeric barcodes.", - "example" => array ( - array ( - "caption" => "7 char numeric - auto check digit", - "content" => "0123456" - ), - array ( - "caption" => "8 char numeric including (wrong) check digit", - "content" => "01234567" - ) - ) - ), - Printer::BARCODE_CODE39 => array ( - "title" => "Code39", - "caption" => "Variable length alphanumeric w/ some special chars.", - "example" => array ( - array ( - "caption" => "Text, numbers, spaces", - "content" => "ABC 012" - ), - array ( - "caption" => "Special characters", - "content" => "$%+-./" - ), - array ( - "caption" => "Extra char (*) Used as start/stop", - "content" => "*TEXT*" - ) - ) - ), - Printer::BARCODE_ITF => array ( - "title" => "ITF", - "caption" => "Variable length numeric w/even number of digits,\nas they are encoded in pairs.", - "example" => array ( - array ( - "caption" => "Numeric- even number of digits", - "content" => "0123456789" - ) - ) - ), - Printer::BARCODE_CODABAR => array ( - "title" => "Codabar", - "caption" => "Varaible length numeric with some allowable\nextra characters. ABCD/abcd must be used as\nstart/stop characters (one at the start, one\nat the end) to distinguish between barcode\napplications.", - "example" => array ( - array ( - "caption" => "Numeric w/ A A start/stop. ", - "content" => "A012345A" - ), - array ( - "caption" => "Extra allowable characters", - "content" => "A012$+-./:A" - ) - ) - ), - Printer::BARCODE_CODE93 => array ( - "title" => "Code93", - "caption" => "Variable length- any ASCII is available", - "example" => array ( - array ( - "caption" => "Text", - "content" => "012abcd" - ) - ) - ), - Printer::BARCODE_CODE128 => array ( - "title" => "Code128", - "caption" => "Variable length- any ASCII is available", - "example" => array ( - array ( - "caption" => "Code set A uppercase & symbols", - "content" => "{A" . "012ABCD" - ), - array ( - "caption" => "Code set B general text", - "content" => "{B" . "012ABCDabcd" - ), - array ( - "caption" => "Code set C compact numbers\n Sending chr(21) chr(32) chr(43)", - "content" => "{C" . chr(21) . chr(32) . chr(43) - ) - ) - ) -); -$printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW); -foreach ($standards as $type => $standard) { - $printer->selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH); - $printer->text($standard ["title"] . "\n"); - $printer->selectPrintMode(); - $printer->text($standard ["caption"] . "\n\n"); - foreach ($standard ["example"] as $id => $barcode) { - $printer->setEmphasis(true); - $printer->text($barcode ["caption"] . "\n"); - $printer->setEmphasis(false); - $printer->text("Content: " . $barcode ["content"] . "\n"); - $printer->barcode($barcode ["content"], $type); - $printer->feed(); - } -} -$printer->cut(); -$printer->close(); diff --git a/htdocs/includes/mike42/escpos-php/example/bit-image.php b/htdocs/includes/mike42/escpos-php/example/bit-image.php deleted file mode 100644 index befebf80b9f..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/bit-image.php +++ /dev/null @@ -1,36 +0,0 @@ - text("These example images are printed with the older\nbit image print command. You should only use\n\$p -> bitImage() if \$p -> graphics() does not\nwork on your printer.\n\n"); - - $printer -> bitImage($tux); - $printer -> text("Regular Tux (bit image).\n"); - $printer -> feed(); - - $printer -> bitImage($tux, Printer::IMG_DOUBLE_WIDTH); - $printer -> text("Wide Tux (bit image).\n"); - $printer -> feed(); - - $printer -> bitImage($tux, Printer::IMG_DOUBLE_HEIGHT); - $printer -> text("Tall Tux (bit image).\n"); - $printer -> feed(); - - $printer -> bitImage($tux, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT); - $printer -> text("Large Tux in correct proportion (bit image).\n"); -} catch (Exception $e) { - /* Images not supported on your PHP, or image file not found */ - $printer -> text($e -> getMessage() . "\n"); -} - -$printer -> cut(); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/character-encodings-with-images.php b/htdocs/includes/mike42/escpos-php/example/character-encodings-with-images.php deleted file mode 100644 index bc99c2f1872..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/character-encodings-with-images.php +++ /dev/null @@ -1,63 +0,0 @@ - selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_EMPHASIZED | Printer::MODE_DOUBLE_WIDTH); - $printer -> text("Implemented languages\n"); - $printer -> selectPrintMode(); - foreach ($inputsOk as $label => $str) { - $printer -> setEmphasis(true); - $printer -> text($label . ":\n"); - $printer -> setEmphasis(false); - foreach ($buffers as $buffer) { - $printer -> setPrintBuffer($buffer); - $printer -> text($str); - } - $printer -> setPrintBuffer($buffers[0]); - } - $printer -> feed(); - - $printer -> selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_EMPHASIZED | Printer::MODE_DOUBLE_WIDTH); - $printer -> text("Works in progress\n"); - $printer -> selectPrintMode(); - foreach ($inputsNotOk as $label => $str) { - $printer -> setEmphasis(true); - $printer -> text($label . ":\n"); - $printer -> setEmphasis(false); - foreach ($buffers as $buffer) { - $printer -> setPrintBuffer($buffer); - $printer -> text($str); - } - $printer -> setPrintBuffer($buffers[0]); - } - $printer -> cut(); - - /* Close printer */ - $printer -> close(); -} catch (Exception $e) { - echo "Couldn't print to this printer: " . $e -> getMessage() . "\n"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/character-encodings.php b/htdocs/includes/mike42/escpos-php/example/character-encodings.php deleted file mode 100644 index a38e99fb9ea..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/character-encodings.php +++ /dev/null @@ -1,60 +0,0 @@ - selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_EMPHASIZED | Printer::MODE_DOUBLE_WIDTH); - $printer -> text("Implemented languages\n"); - $printer -> selectPrintMode(); - foreach ($inputsOk as $label => $str) { - $printer -> setEmphasis(true); - $printer -> text($label . ":\n"); - $printer -> setEmphasis(false); - $printer -> text($str); - } - $printer -> feed(); - - $printer -> selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_EMPHASIZED | Printer::MODE_DOUBLE_WIDTH); - $printer -> text("Works in progress\n"); - $printer -> selectPrintMode(); - foreach ($inputsNotOk as $label => $str) { - $printer -> setEmphasis(true); - $printer -> text($label . ":\n"); - $printer -> setEmphasis(false); - $printer -> text($str); - } - $printer -> cut(); - - /* Close printer */ - $printer -> close(); -} catch (Exception $e) { - echo "Couldn't print to this printer: " . $e -> getMessage() . "\n"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/character-tables.php b/htdocs/includes/mike42/escpos-php/example/character-tables.php deleted file mode 100644 index d2ab8bbcfa1..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/character-tables.php +++ /dev/null @@ -1,75 +0,0 @@ - getCodePages(); -$first = true; // Print larger table for first code-page. -foreach ($codePages as $table => $page) { - /* Change printer code page */ - $printer -> selectCharacterTable(255); - $printer -> selectCharacterTable($table); - /* Select & print a label for it */ - $label = $page -> getId(); - if (!$page -> isEncodable()) { - $label= " (not supported)"; - } - $printer -> setEmphasis(true); - $printer -> textRaw("Table $table: $label\n"); - $printer -> setEmphasis(false); - if (!$page -> isEncodable() && !$verbose) { - continue; // Skip non-recognised - } - /* Print a table of available characters (first table is larger than subsequent ones */ - if ($first) { - $first = false; - compactCharTable($printer, 1, true); - } else { - compactCharTable($printer); - } -} -$printer -> cut(); -$printer -> close(); - -function compactCharTable($printer, $start = 4, $header = false) -{ - /* Output a compact character table for the current encoding */ - $chars = str_repeat(' ', 256); - for ($i = 0; $i < 255; $i++) { - $chars[$i] = ($i > 32 && $i != 127) ? chr($i) : ' '; - } - if ($header) { - $printer -> setEmphasis(true); - $printer -> textRaw(" 0123456789ABCDEF0123456789ABCDEF\n"); - $printer -> setEmphasis(false); - } - for ($y = $start; $y < 8; $y++) { - $printer -> setEmphasis(true); - $printer -> textRaw(strtoupper(dechex($y * 2)) . " "); - $printer -> setEmphasis(false); - $printer -> textRaw(substr($chars, $y * 32, 32) . "\n"); - } -} diff --git a/htdocs/includes/mike42/escpos-php/example/customer-display.php b/htdocs/includes/mike42/escpos-php/example/customer-display.php deleted file mode 100644 index 47947789540..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/customer-display.php +++ /dev/null @@ -1,51 +0,0 @@ - feed(); - $display -> text($line); - usleep(500000); -} - -// Finish by showing "Hello World" -$display -> clear(); -$display -> text("Hello World\n"); - -// Dont forget to close the device -$display -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/demo.php b/htdocs/includes/mike42/escpos-php/example/demo.php deleted file mode 100644 index f0e357ed431..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/demo.php +++ /dev/null @@ -1,171 +0,0 @@ - - */ -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") { - $mode |= $modes[$j]; - } - } - $printer -> selectPrintMode($mode); - $printer -> text("ABCDEFGHIJabcdefghijk\n"); -} -$printer -> selectPrintMode(); // Reset -$printer -> cut(); - -/* Underline */ -for ($i = 0; $i < 3; $i++) { - $printer -> setUnderline($i); - $printer -> text("The quick brown fox jumps over the lazy dog\n"); -} -$printer -> setUnderline(0); // Reset -$printer -> cut(); - -/* Cuts */ -$printer -> text("Partial cut\n(not available on all printers)\n"); -$printer -> cut(Printer::CUT_PARTIAL); -$printer -> text("Full cut\n"); -$printer -> cut(Printer::CUT_FULL); - -/* Emphasis */ -for ($i = 0; $i < 2; $i++) { - $printer -> setEmphasis($i == 1); - $printer -> text("The quick brown fox jumps over the lazy dog\n"); -} -$printer -> setEmphasis(false); // Reset -$printer -> cut(); - -/* Double-strike (looks basically the same as emphasis) */ -for ($i = 0; $i < 2; $i++) { - $printer -> setDoubleStrike($i == 1); - $printer -> text("The quick brown fox jumps over the lazy dog\n"); -} -$printer -> setDoubleStrike(false); -$printer -> cut(); - -/* Fonts (many printers do not have a 'Font C') */ -$fonts = array( - Printer::FONT_A, - Printer::FONT_B, - Printer::FONT_C); -for ($i = 0; $i < count($fonts); $i++) { - $printer -> setFont($fonts[$i]); - $printer -> text("The quick brown fox jumps over the lazy dog\n"); -} -$printer -> setFont(); // Reset -$printer -> cut(); - -/* Justification */ -$justification = array( - Printer::JUSTIFY_LEFT, - Printer::JUSTIFY_CENTER, - Printer::JUSTIFY_RIGHT); -for ($i = 0; $i < count($justification); $i++) { - $printer -> setJustification($justification[$i]); - $printer -> text("A man a plan a canal panama\n"); -} -$printer -> setJustification(); // Reset -$printer -> cut(); - -/* Barcodes - see barcode.php for more detail */ -$printer -> setBarcodeHeight(80); -$printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW); -$printer -> barcode("9876"); -$printer -> feed(); -$printer -> cut(); - -/* Graphics - this demo will not work on some non-Epson printers */ -try { - $logo = EscposImage::load("resources/escpos-php.png", false); - $imgModes = array( - Printer::IMG_DEFAULT, - Printer::IMG_DOUBLE_WIDTH, - Printer::IMG_DOUBLE_HEIGHT, - Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT - ); - foreach ($imgModes as $mode) { - $printer -> graphics($logo, $mode); - } -} catch (Exception $e) { - /* Images not supported on your PHP, or image file not found */ - $printer -> text($e -> getMessage() . "\n"); -} -$printer -> cut(); - -/* Bit image */ -try { - $logo = EscposImage::load("resources/escpos-php.png", false); - $imgModes = array( - Printer::IMG_DEFAULT, - Printer::IMG_DOUBLE_WIDTH, - Printer::IMG_DOUBLE_HEIGHT, - Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT - ); - foreach ($imgModes as $mode) { - $printer -> bitImage($logo, $mode); - } -} catch (Exception $e) { - /* Images not supported on your PHP, or image file not found */ - $printer -> text($e -> getMessage() . "\n"); -} -$printer -> cut(); - -/* QR Code - see also the more in-depth demo at qr-code.php */ -$testStr = "Testing 123"; -$models = array( - Printer::QR_MODEL_1 => "QR Model 1", - Printer::QR_MODEL_2 => "QR Model 2 (default)", - Printer::QR_MICRO => "Micro QR code\n(not supported on all printers)"); -foreach ($models as $model => $name) { - $printer -> qrCode($testStr, Printer::QR_ECLEVEL_L, 3, $model); - $printer -> text("$name\n"); - $printer -> feed(); -} -$printer -> cut(); - -/* Pulse */ -$printer -> pulse(); - -/* Always close the printer! On some PrintConnectors, no actual - * data is sent until the printer is closed. */ -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/graphics.php b/htdocs/includes/mike42/escpos-php/example/graphics.php deleted file mode 100644 index 49b02b9b0d9..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/graphics.php +++ /dev/null @@ -1,36 +0,0 @@ - graphics($tux); - $printer -> text("Regular Tux.\n"); - $printer -> feed(); - - $printer -> graphics($tux, Printer::IMG_DOUBLE_WIDTH); - $printer -> text("Wide Tux.\n"); - $printer -> feed(); - - $printer -> graphics($tux, Printer::IMG_DOUBLE_HEIGHT); - $printer -> text("Tall Tux.\n"); - $printer -> feed(); - - $printer -> graphics($tux, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT); - $printer -> text("Large Tux in correct proportion.\n"); - - $printer -> cut(); -} catch (Exception $e) { - /* Images not supported on your PHP, or image file not found */ - $printer -> text($e -> getMessage() . "\n"); -} - -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/interface/README.md b/htdocs/includes/mike42/escpos-php/example/interface/README.md deleted file mode 100644 index 96fe2eed2fb..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/interface/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Interfaces ----------- -This directory contains boilerpalte code to show you how to open a print connector -to printers which are connected in different ways. - -To get a list of supported interfaces and operating systems, see the main README.md file for the project. - -If you have a printer interface with no example, and you want to help put one together, then please lodge a request on the bug tracker: https://github.com/mike42/escpos-php/issues diff --git a/htdocs/includes/mike42/escpos-php/example/interface/cups.php b/htdocs/includes/mike42/escpos-php/example/interface/cups.php deleted file mode 100644 index 8b65ab3d4d9..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/interface/cups.php +++ /dev/null @@ -1,19 +0,0 @@ - text("Hello World!\n"); - $printer -> cut(); - - /* Close printer */ - $printer -> close(); -} catch (Exception $e) { - echo "Couldn't print to this printer: " . $e -> getMessage() . "\n"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/interface/ethernet.php b/htdocs/includes/mike42/escpos-php/example/interface/ethernet.php deleted file mode 100644 index 129af5ce3aa..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/interface/ethernet.php +++ /dev/null @@ -1,22 +0,0 @@ - text("Hello World!\n"); - $printer -> cut(); - - /* Close printer */ - $printer -> close(); -} catch (Exception $e) { - echo "Couldn't print to this printer: " . $e -> getMessage() . "\n"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/interface/linux-usb.php b/htdocs/includes/mike42/escpos-php/example/interface/linux-usb.php deleted file mode 100644 index 2b390f658b2..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/interface/linux-usb.php +++ /dev/null @@ -1,33 +0,0 @@ - text("Hello World!\n"); - $printer -> cut(); - - /* Close printer */ - $printer -> close(); -} catch (Exception $e) { - echo "Couldn't print to this printer: " . $e -> getMessage() . "\n"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/interface/smb.php b/htdocs/includes/mike42/escpos-php/example/interface/smb.php deleted file mode 100644 index fac54b342d1..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/interface/smb.php +++ /dev/null @@ -1,52 +0,0 @@ - testfile - * ## If you need authentication, use "net use" to hook up the printer: - * # net use "\\computername\Receipt Printer" /user:Guest - * # net use "\\computername\Receipt Printer" /user:Bob secret - * # net use "\\computername\Receipt Printer" /user:workgroup\Bob secret - * copy testfile "\\computername\Receipt Printer" - * del testfile - * - * GNU/Linux: - * # No authentication - * echo "Hello World" | smbclient "//computername/Receipt Printer" -c "print -" -N - * # Guest login - * echo "Hello World" | smbclient "//computername/Receipt Printer" -U Guest -c "print -" -N - * # Basic username/password - * echo "Hello World" | smbclient "//computername/Receipt Printer" secret -U "Bob" -c "print -" - * # Including domain name - * echo "Hello World" | smbclient "//computername/Receipt Printer" secret -U "workgroup\\Bob" -c "print -" - */ -try { - // Enter the share name for your printer here, as a smb:// url format - $connector = new WindowsPrintConnector("smb://computername/Receipt Printer"); - //$connector = new WindowsPrintConnector("smb://Guest@computername/Receipt Printer"); - //$connector = new WindowsPrintConnector("smb://FooUser:secret@computername/workgroup/Receipt Printer"); - //$connector = new WindowsPrintConnector("smb://User:secret@computername/Receipt Printer"); - - /* 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"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/interface/windows-lpt.php b/htdocs/includes/mike42/escpos-php/example/interface/windows-lpt.php deleted file mode 100644 index e8fef286bd8..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/interface/windows-lpt.php +++ /dev/null @@ -1,31 +0,0 @@ - LPT1 - */ -try { - $connector = new WindowsPrintConnector("LPT1"); - - // A FilePrintConnector will also work, but on non-Windows systems, writes - // to an actual file called 'LPT1' rather than giving a useful error. - // $connector = new FilePrintConnector("LPT1"); - - /* 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"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/interface/windows-usb.php b/htdocs/includes/mike42/escpos-php/example/interface/windows-usb.php deleted file mode 100644 index 79776994231..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/interface/windows-usb.php +++ /dev/null @@ -1,34 +0,0 @@ - testfile - * copy testfile "\\%COMPUTERNAME%\Receipt Printer" - * del testfile - */ -try { - // Enter the share name for your USB printer here - $connector = null; - //$connector = new WindowsPrintConnector("Receipt Printer"); - - /* 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"; -} diff --git a/htdocs/includes/mike42/escpos-php/example/margins-and-spacing.php b/htdocs/includes/mike42/escpos-php/example/margins-and-spacing.php deleted file mode 100644 index 296a7b0bc73..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/margins-and-spacing.php +++ /dev/null @@ -1,48 +0,0 @@ - setEmphasis(true); -$printer -> text("Line spacing\n"); -$printer -> setEmphasis(false); -foreach(array(16, 32, 64, 128, 255) as $spacing) { - $printer -> setLineSpacing($spacing); - $printer -> text("Spacing $spacing: The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.\n"); -} -$printer -> setLineSpacing(); // Back to default -*/ - -/* Stuff around with left margin */ -$printer -> setEmphasis(true); -$printer -> text("Left margin\n"); -$printer -> setEmphasis(false); -$printer -> text("Default left\n"); -foreach(array(1, 2, 4, 8, 16, 32, 64, 128, 256, 512) as $margin) { - $printer -> setPrintLeftMargin($margin); - $printer -> text("left margin $margin\n"); -} -/* Reset left */ -$printer -> setPrintLeftMargin(0); - -/* Stuff around with page width */ -$printer -> setEmphasis(true); -$printer -> text("Page width\n"); -$printer -> setEmphasis(false); -$printer -> setJustification(Printer::JUSTIFY_RIGHT); -$printer -> text("Default width\n"); -foreach(array(512, 256, 128, 64) as $width) { - $printer -> setPrintWidth($width); - $printer -> text("page width $width\n"); -} - -/* Printer shutdown */ -$printer -> cut(); -$printer -> close(); - diff --git a/htdocs/includes/mike42/escpos-php/example/pdf417-code.php b/htdocs/includes/mike42/escpos-php/example/pdf417-code.php deleted file mode 100644 index 6735ae6ee4d..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/pdf417-code.php +++ /dev/null @@ -1,95 +0,0 @@ - pdf417Code($testStr); -$printer -> text("Most simple example\n"); -$printer -> feed(); - -// Demo that alignment is the same as text -$printer -> setJustification(Printer::JUSTIFY_CENTER); -$printer -> pdf417Code($testStr, 3, 3, 2); -$printer -> text("Same content, narrow and centred\n"); -$printer -> setJustification(); -$printer -> feed(); - -// Demo of error correction -title($printer, "Error correction\n"); -$ec = array(0.1, 0.5, 1.0, 2.0, 4.0); -foreach ($ec as $level) { - $printer -> pdf417Code($testStr, 3, 3, 0, $level); - $printer -> text("Error correction ratio $level\n"); - $printer -> feed(); -} - -// Change size -title($printer, "Pixel size\n"); -$sizes = array( - 2 => "(minimum)", - 3 => "(default)", - 4 => "", - 8 => "(maximum)"); -foreach ($sizes as $size => $label) { - $printer -> pdf417Code($testStr, $size); - $printer -> text("Module width $size dots $label\n"); - $printer -> feed(); -} - -// Change height -title($printer, "Height multiplier\n"); -$sizes = array( - 2 => "(minimum)", - 3 => "(default)", - 4 => "", - 8 => "(maximum)"); -foreach ($sizes as $size => $label) { - $printer -> pdf417Code($testStr, 3, $size); - $printer -> text("Height multiplier $size $label\n"); - $printer -> feed(); -} - -// Chage data column count -title($printer, "Data column count\n"); -$columnCounts = array( - 0 => "(auto, default)", - 1 => "", - 2 => "", - 3 => "", - 4 => "", - 5 => "", - 30 => "(maximum, doesnt fit!)"); -foreach ($columnCounts as $columnCount => $label) { - $printer -> pdf417Code($testStr, 3, 3, $columnCount); - $printer -> text("Column count $columnCount $label\n"); - $printer -> feed(); -} - -// Change options -title($printer, "Options\n"); -$models = array( - Printer::PDF417_STANDARD => "Standard", - Printer::PDF417_TRUNCATED => "Truncated"); -foreach ($models as $model => $name) { - $printer -> pdf417Code($testStr, 3, 3, 0, 0.10, $model); - $printer -> text("$name\n"); - $printer -> feed(); -} - -// Cut & close -$printer -> cut(); -$printer -> close(); - -function title(Printer $printer, $str) -{ - $printer -> selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH); - $printer -> text($str); - $printer -> selectPrintMode(); -} diff --git a/htdocs/includes/mike42/escpos-php/example/print-from-html.php b/htdocs/includes/mike42/escpos-php/example/print-from-html.php deleted file mode 100644 index 640132e11b0..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/print-from-html.php +++ /dev/null @@ -1,86 +0,0 @@ - 225 below) and printing w/ Escpos::IMG_DOUBLE_WIDTH | Escpos::IMG_DOUBLE_HEIGHT - */ -try { - /* Set up command */ - $source = __DIR__ . "/resources/document.html"; - $width = 550; - $dest = tempnam(sys_get_temp_dir(), 'escpos') . ".png"; - $command = sprintf( - "xvfb-run wkhtmltoimage -n -q --width %s %s %s", - escapeshellarg($width), - escapeshellarg($source), - escapeshellarg($dest) - ); - - /* Test for dependencies */ - foreach (array("xvfb-run", "wkhtmltoimage") as $cmd) { - $testCmd = sprintf("which %s", escapeshellarg($cmd)); - exec($testCmd, $testOut, $testStatus); - if ($testStatus != 0) { - throw new Exception("You require $cmd but it could not be found"); - } - } - - - /* Run wkhtmltoimage */ - $descriptors = array( - 1 => array("pipe", "w"), - 2 => array("pipe", "w"), - ); - $process = proc_open($command, $descriptors, $fd); - if (is_resource($process)) { - /* Read stdout */ - $outputStr = stream_get_contents($fd[1]); - fclose($fd[1]); - /* Read stderr */ - $errorStr = stream_get_contents($fd[2]); - fclose($fd[2]); - /* Finish up */ - $retval = proc_close($process); - if ($retval != 0) { - throw new Exception("Command $cmd failed: $outputStr $errorStr"); - } - } else { - throw new Exception("Command '$cmd' failed to start."); - } - - /* Load up the image */ - try { - $img = EscposImage::load($dest); - } catch (Exception $e) { - unlink($dest); - throw $e; - } - unlink($dest); - - /* Print it */ - $printer -> bitImage($img); // bitImage() seems to allow larger images than graphics() on the TM-T20. bitImageColumnFormat() is another option. - $printer -> cut(); -} catch (Exception $e) { - echo $e -> getMessage(); -} finally { - $printer -> close(); -} diff --git a/htdocs/includes/mike42/escpos-php/example/print-from-pdf.php b/htdocs/includes/mike42/escpos-php/example/print-from-pdf.php deleted file mode 100644 index 23469e8a00f..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/print-from-pdf.php +++ /dev/null @@ -1,78 +0,0 @@ - graphics($page); - } - $printer -> cut(); -} catch (Exception $e) { - /* - * loadPdf() throws exceptions if files or not found, or you don't have the - * imagick extension to read PDF's - */ - echo $e -> getMessage() . "\n"; -} finally { - $printer -> close(); -} - - -/* - * 2: Speed up printing by roughly halving the resolution, and printing double-size. - * This gives a 75% speed increase at the expense of some quality. - * - * Reduce the page width further if necessary: if it extends past the printing area, your prints will be very slow. - */ -$connector = new FilePrintConnector("php://stdout"); -$printer = new Printer($connector); -$pdf = 'resources/document.pdf'; -$pages = ImagickEscposImage::loadPdf($pdf, 260); -foreach ($pages as $page) { - $printer -> graphics($page, Printer::IMG_DOUBLE_HEIGHT | Printer::IMG_DOUBLE_WIDTH); -} -$printer -> cut(); -$printer -> close(); - -/* - * 3: PDF printing still too slow? If you regularly print the same files, serialize & compress your - * EscposImage objects (after printing[1]), instead of throwing them away. - * - * (You can also do this to print logos on computers which don't have an - * image processing library, by preparing a serialized version of your logo on your PC) - * - * [1]After printing, the pixels are loaded and formatted for the print command you used, so even a raspberry pi can print complex PDF's quickly. - */ -$connector = new FilePrintConnector("php://stdout"); -$printer = new Printer($connector); -$pdf = 'resources/document.pdf'; -$ser = 'resources/document.z'; -if (!file_exists($ser)) { - $pages = ImagickEscposImage::loadPdf($pdf); -} else { - $pages = unserialize(gzuncompress(file_get_contents($ser))); -} - -foreach ($pages as $page) { - $printer -> graphics($page); -} -$printer -> cut(); -$printer -> close(); - -if (!file_exists($ser)) { - file_put_contents($ser, gzcompress(serialize($pages))); -} diff --git a/htdocs/includes/mike42/escpos-php/example/qr-code.php b/htdocs/includes/mike42/escpos-php/example/qr-code.php deleted file mode 100644 index f57c2b8270d..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/qr-code.php +++ /dev/null @@ -1,86 +0,0 @@ - qrCode($testStr); -$printer -> text("Most simple example\n"); -$printer -> feed(); - -// Demo that alignment is the same as text -$printer -> setJustification(Printer::JUSTIFY_CENTER); -$printer -> qrCode($testStr); -$printer -> text("Same example, centred\n"); -$printer -> setJustification(); -$printer -> feed(); - -// Demo of numeric data being packed more densly -title($printer, "Data encoding\n"); -$test = array( - "Numeric" => "0123456789012345678901234567890123456789", - "Alphanumeric" => "abcdefghijklmnopqrstuvwxyzabcdefghijklmn", - "Binary" => str_repeat("\0", 40)); -foreach ($test as $type => $data) { - $printer -> qrCode($data); - $printer -> text("$type\n"); - $printer -> feed(); -} - -// Demo of error correction -title($printer, "Error correction\n"); -$ec = array( - Printer::QR_ECLEVEL_L => "L", - Printer::QR_ECLEVEL_M => "M", - Printer::QR_ECLEVEL_Q => "Q", - Printer::QR_ECLEVEL_H => "H"); -foreach ($ec as $level => $name) { - $printer -> qrCode($testStr, $level); - $printer -> text("Error correction $name\n"); - $printer -> feed(); -} - -// Change size -title($printer, "Pixel size\n"); -$sizes = array( - 1 => "(minimum)", - 2 => "", - 3 => "(default)", - 4 => "", - 5 => "", - 10 => "", - 16 => "(maximum)"); -foreach ($sizes as $size => $label) { - $printer -> qrCode($testStr, Printer::QR_ECLEVEL_L, $size); - $printer -> text("Pixel size $size $label\n"); - $printer -> feed(); -} - -// Change model -title($printer, "QR model\n"); -$models = array( - Printer::QR_MODEL_1 => "QR Model 1", - Printer::QR_MODEL_2 => "QR Model 2 (default)", - Printer::QR_MICRO => "Micro QR code\n(not supported on all printers)"); -foreach ($models as $model => $name) { - $printer -> qrCode($testStr, Printer::QR_ECLEVEL_L, 3, $model); - $printer -> text("$name\n"); - $printer -> feed(); -} - -// Cut & close -$printer -> cut(); -$printer -> close(); - -function title(Printer $printer, $str) -{ - $printer -> selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH); - $printer -> text($str); - $printer -> selectPrintMode(); -} diff --git a/htdocs/includes/mike42/escpos-php/example/rawbt-receipt.html b/htdocs/includes/mike42/escpos-php/example/rawbt-receipt.html deleted file mode 100644 index c3d307a94d1..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/rawbt-receipt.html +++ /dev/null @@ -1,76 +0,0 @@ - - -
- -
-- - window.location.href = ajax_backend_data; - --
-
- This is a simple document. For receipts involving complex formatting,
- non-monospace fonts, advanced character encodings, or vector graphics,
- you can always create and render HTML instead.
-
- The printing will be a lot slower, but you have full access to things like unicode and SVG. -
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor - in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla - pariatur.
-Excepteur sint occaecat cupidatat non proident, sunt in culpa - qui officia deserunt mollit anim id est laborum.
- - diff --git a/htdocs/includes/mike42/escpos-php/example/resources/document.odt b/htdocs/includes/mike42/escpos-php/example/resources/document.odt deleted file mode 100644 index 4bbd7f98b65..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/document.odt and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/resources/document.pdf b/htdocs/includes/mike42/escpos-php/example/resources/document.pdf deleted file mode 100644 index 93a702337f1..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/document.pdf and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/resources/document.z b/htdocs/includes/mike42/escpos-php/example/resources/document.z deleted file mode 100644 index c19e213227a..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/document.z and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/resources/escpos-php-small.png b/htdocs/includes/mike42/escpos-php/example/resources/escpos-php-small.png deleted file mode 100644 index 3c74d2d57a2..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/escpos-php-small.png and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/resources/escpos-php.png b/htdocs/includes/mike42/escpos-php/example/resources/escpos-php.png deleted file mode 100644 index feee2d71cc2..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/escpos-php.png and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/resources/rawbtlogo.png b/htdocs/includes/mike42/escpos-php/example/resources/rawbtlogo.png deleted file mode 100644 index 999abab33e2..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/rawbtlogo.png and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/resources/tulips.png b/htdocs/includes/mike42/escpos-php/example/resources/tulips.png deleted file mode 100644 index a0e681cf0ff..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/tulips.png and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/resources/tux.png b/htdocs/includes/mike42/escpos-php/example/resources/tux.png deleted file mode 100644 index e32f8d94534..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/example/resources/tux.png and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/example/specific/123-code128-barcode.php b/htdocs/includes/mike42/escpos-php/example/specific/123-code128-barcode.php deleted file mode 100644 index b87e44981e0..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/123-code128-barcode.php +++ /dev/null @@ -1,21 +0,0 @@ - setJustification(Printer::JUSTIFY_CENTER); -$printer -> setBarcodeHeight(48); -$printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW); -foreach(array($a, $b, $c) as $item) { - $printer -> barcode($item, Printer::BARCODE_CODE128); - $printer -> feed(1); -} -$printer -> cut(); -$printer -> close(); - diff --git a/htdocs/includes/mike42/escpos-php/example/specific/141-custom-command.php b/htdocs/includes/mike42/escpos-php/example/specific/141-custom-command.php deleted file mode 100644 index 6e3bed70d0b..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/141-custom-command.php +++ /dev/null @@ -1,55 +0,0 @@ -getPrintConnector()->write($barcodeCommand); -$printer->cut(); -$printer->close(); - -/** - * Generate two characters for a number: In lower and higher parts, or more parts as needed. - * - * @param int $input - * Input number - * @param int $length - * The number of bytes to output (1 - 4). - */ -function intLowHigh($input, $length) -{ - $outp = ""; - for ($i = 0; $i < $length; $i ++) { - $outp .= chr($input % 256); - $input = (int) ($input / 256); - } - return $outp; -} -?> \ No newline at end of file diff --git a/htdocs/includes/mike42/escpos-php/example/specific/148-data-uri.php b/htdocs/includes/mike42/escpos-php/example/specific/148-data-uri.php deleted file mode 100644 index 74759146712..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/148-data-uri.php +++ /dev/null @@ -1,35 +0,0 @@ - setResourceLimit(6, 1); // Prevent libgomp1 segfaults, grumble grumble. -$imagick -> readImageBlob($imageBlob, "input.png"); - -// Load Imagick straight into an EscposImage object -$im = new ImagickEscposImage(); -$im -> readImageFromImagick($imagick); - -// Do a test print to make sure that this EscposImage object has the right data -// (should see a tiny bullet point) -$connector = new FilePrintConnector("php://output"); -$printer = new Printer($connector); -$printer -> bitImage($im); -$printer -> cut(); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/235-get-data.php b/htdocs/includes/mike42/escpos-php/example/specific/235-get-data.php deleted file mode 100644 index c3607c868b3..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/235-get-data.php +++ /dev/null @@ -1,28 +0,0 @@ - text("Hello world!\n"); -$printer -> cut(); - -// Get the data out as a string -$data = $connector -> getData(); - -// Return it, check the manual for specifics. -header('Content-type: application/octet-stream'); -header('Content-Length: '.strlen($data)); -echo $data; - -// Close the printer when done. -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/29-latvian-star-tup592.php b/htdocs/includes/mike42/escpos-php/example/specific/29-latvian-star-tup592.php deleted file mode 100644 index 73613100abb..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/29-latvian-star-tup592.php +++ /dev/null @@ -1,25 +0,0 @@ - text("Glāžšķūņa rūķīši dzērumā čiepj Baha koncertflīģeļu vākus\n"); -$printer -> cut(); -$printer -> close(); - -/* Option 2: Image-based output (formatting not available using this output) */ -$buffer = new ImagePrintBuffer(); -$connector = new FilePrintConnector("php://stdout"); -$printer = new Printer($connector, $profile); -$printer -> setPrintBuffer($buffer); -$printer -> text("Glāžšķūņa rūķīši dzērumā čiepj Baha koncertflīģeļu vākus\n"); -$printer -> cut(); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/32-german-tm-t20-ii-custom-command.php b/htdocs/includes/mike42/escpos-php/example/specific/32-german-tm-t20-ii-custom-command.php deleted file mode 100644 index 29b6b3fc638..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/32-german-tm-t20-ii-custom-command.php +++ /dev/null @@ -1,39 +0,0 @@ - getPrintConnector() -> write($cmd); -$printer -> text("Beispieltext in Deutsch\n"); -$printer -> cut(); -$printer -> close(); -/* - * Hex-dump of output confirms that ESC V 1 being sent: - * - * 0000000 033 @ 033 V 001 B e i s p i e l t e x - * 0000010 t i n D e u t s c h \n 035 V A - * 0000020 003 - */ diff --git a/htdocs/includes/mike42/escpos-php/example/specific/33-spanish-seypos-prp-300.php b/htdocs/includes/mike42/escpos-php/example/specific/33-spanish-seypos-prp-300.php deleted file mode 100644 index 90bdc63fb5c..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/33-spanish-seypos-prp-300.php +++ /dev/null @@ -1,19 +0,0 @@ - text("El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro.\n"); -$printer -> cut(); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/37-chinese.php b/htdocs/includes/mike42/escpos-php/example/specific/37-chinese.php deleted file mode 100644 index d14790f47d5..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/37-chinese.php +++ /dev/null @@ -1,24 +0,0 @@ - textChinese("艾德蒙 AOC E2450SWH 23.6吋 LED液晶寬螢幕特價$ 19900\n\n"); - -// Note that on the printer tested (ZJ5890), the font only contained simplified characters. -$printer -> textChinese("示例文本打印机!\n\n"); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/39-currency-symbols.php b/htdocs/includes/mike42/escpos-php/example/specific/39-currency-symbols.php deleted file mode 100644 index b960ee681c3..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/39-currency-symbols.php +++ /dev/null @@ -1,77 +0,0 @@ - text("€ 9,95\n"); -$printer -> text("£ 9.95\n"); -$printer -> text("$ 9.95\n"); -$printer -> text("¥ 9.95\n"); -$printer -> cut(); -$printer -> close(); - -/* Option 2: Image-based output (formatting not available using this output). */ -$buffer = new ImagePrintBuffer(); -$connector = new FilePrintConnector("php://stdout"); -$printer = new Printer($connector, $profile); -$printer -> setPrintBuffer($buffer); -$printer -> text("€ 9,95\n"); -$printer -> text("£ 9.95\n"); -$printer -> text("$ 9.95\n"); -$printer -> text("¥ 9.95\n"); -$printer -> cut(); -$printer -> close(); - -/* - Option 3: If the printer is configured to print in a specific code - page, you can set up a CapabilityProfile which either references its - iconv encoding name, or includes all of the available characters. - - Here, we make use of CP858 for its inclusion of currency symbols which - are not available in CP437. CP858 has good printer support, but is not - included in all iconv builds. -*/ -class CustomCapabilityProfile extends CapabilityProfile -{ - function getCustomCodePages() - { - /* - * Example to print in a specific, user-defined character set - * on a printer which has been configured to use i - */ - return array( - 'CP858' => "ÇüéâäàåçêëèïîìÄÅ" . - "ÉæÆôöòûùÿÖÜø£Ø×ƒ" . - "áíóúñѪº¿®¬½¼¡«»" . - "░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐" . - "└┴┬├─┼ãÃ╚╔╩╦╠═╬¤" . - "ðÐÊËÈ€ÍÎÏ┘┌█▄¦Ì▀" . - "ÓßÔÒõÕµþÞÚÛÙýݯ´" . - " ±‗¾¶§÷¸°¨·¹³²■ "); - } - - function getSupportedCodePages() - { - return array( - 0 => 'custom:CP858'); - } -} - -$connector = new FilePrintConnector("php://stdout"); -$profile = CustomCapabilityProfile::getInstance(); -$printer = new Printer($connector, $profile); -$printer -> text("€ 9,95\n"); -$printer -> text("£ 9.95\n"); -$printer -> text("$ 9.95\n"); -$printer -> text("¥ 9.95\n"); - -$printer -> cut(); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/44-pound-symbol-star-tsp650.php b/htdocs/includes/mike42/escpos-php/example/specific/44-pound-symbol-star-tsp650.php deleted file mode 100644 index 3e7e6a2e48b..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/44-pound-symbol-star-tsp650.php +++ /dev/null @@ -1,35 +0,0 @@ - textRaw("\x9C"); // based on position in CP437 -$printer -> text(" 1.95\n"); - -// B) Manually encoded UTF8 pound symbol. Tests that the driver correctly -// encodes this as CP437. -$printer -> text(base64_decode("wqM=") . " 2.95\n"); - -// C) Pasted in file. Tests that your files are being saved as UTF-8, which -// escpos-php is able to convert automatically to a mix of code pages. -$printer -> text("£ 3.95\n"); - -$printer -> cut(); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/50-P-822D-greek.php b/htdocs/includes/mike42/escpos-php/example/specific/50-P-822D-greek.php deleted file mode 100644 index 1651f44a7fa..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/50-P-822D-greek.php +++ /dev/null @@ -1,19 +0,0 @@ - text($text . "\n"); -$printer -> cut(); - -// Close the connection -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/54-gfx-sidebyside.php b/htdocs/includes/mike42/escpos-php/example/specific/54-gfx-sidebyside.php deleted file mode 100644 index 2becce742d4..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/54-gfx-sidebyside.php +++ /dev/null @@ -1,64 +0,0 @@ - setJustification(Printer::JUSTIFY_CENTER); - $printer -> graphics($img); - $printer -> cut(); - } finally { - // Always close the connection - $printer -> close(); - } -} catch (Exception $e) { - // Print out any errors: Eg. printer connection, image loading & external image manipulation. - echo $e -> getMessage() . "\n"; - echo $e -> getTraceAsString(); -} finally { - unlink($imgCombined_path); - unlink($tmpf_path); -} diff --git a/htdocs/includes/mike42/escpos-php/example/specific/6-arabic-epos-tep-220m.php b/htdocs/includes/mike42/escpos-php/example/specific/6-arabic-epos-tep-220m.php deleted file mode 100644 index 5994b7a81c7..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/6-arabic-epos-tep-220m.php +++ /dev/null @@ -1,74 +0,0 @@ - utf8Glyphs($textUtf8, $maxChars); -$textLine = explode("\n", $textLtr); - -/* - * Set up and use an image print buffer with a suitable font - */ -$buffer = new ImagePrintBuffer(); -$buffer -> setFont($fontPath); -$buffer -> setFontSize($fontSize); - -$profile = CapabilityProfile::load("TEP-200M"); -$connector = new FilePrintConnector("php://output"); - // = new WindowsPrintConnector("LPT2"); - // Windows LPT2 was used in the bug tracker - -$printer = new Printer($connector, $profile); -$printer -> setPrintBuffer($buffer); - -$printer -> setJustification(Printer::JUSTIFY_RIGHT); -foreach($textLine as $text) { - // Print each line separately. We need to do this since Imagick thinks - // text is left-to-right - $printer -> text($text . "\n"); -} - -$printer -> cut(); -$printer -> close(); diff --git a/htdocs/includes/mike42/escpos-php/example/specific/62-greek-symbol-swap.php b/htdocs/includes/mike42/escpos-php/example/specific/62-greek-symbol-swap.php deleted file mode 100644 index 5ea995e5aed..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/62-greek-symbol-swap.php +++ /dev/null @@ -1,15 +0,0 @@ - text("Μιχάλης Νίκος\n"); -$printer -> cut(); -$printer -> close(); - -?> diff --git a/htdocs/includes/mike42/escpos-php/example/specific/68-redblack.php b/htdocs/includes/mike42/escpos-php/example/specific/68-redblack.php deleted file mode 100644 index 142a83ab3e7..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/68-redblack.php +++ /dev/null @@ -1,21 +0,0 @@ - text("Hello World!\n"); - $printer -> setColor(Printer::COLOR_2); - $printer -> text("Red?!\n"); - $printer -> setColor(Printer::COLOR_1); - $printer -> text("Default color again?!\n"); - $printer -> cut(); -} finally { - /* Always close the printer! */ - $printer -> close(); -} diff --git a/htdocs/includes/mike42/escpos-php/example/specific/97-dithering.php b/htdocs/includes/mike42/escpos-php/example/specific/97-dithering.php deleted file mode 100644 index 312df749eb1..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/97-dithering.php +++ /dev/null @@ -1,28 +0,0 @@ - bitImage($img1); - - /* Load with optimisations disabled, forcing the use of PHP to convert the - pixels, which uses a threshold and is much slower. - */ - $img2 = EscposImage::load(__DIR__ . '/../resources/tulips.png', false); - $printer -> bitImage($img2); - $printer -> cut(); -} finally { - /* Always close the printer! */ - $printer -> close(); -} diff --git a/htdocs/includes/mike42/escpos-php/example/specific/README.md b/htdocs/includes/mike42/escpos-php/example/specific/README.md deleted file mode 100644 index 7433e7aa247..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/specific/README.md +++ /dev/null @@ -1,7 +0,0 @@ -Specific examples ------------------ - -These examples are designed for specific combinations of language, -printer and interface. - -They are documented here because the general examples all set up the printer in a similar way. diff --git a/htdocs/includes/mike42/escpos-php/example/text-size.php b/htdocs/includes/mike42/escpos-php/example/text-size.php deleted file mode 100644 index 01bf33dd699..00000000000 --- a/htdocs/includes/mike42/escpos-php/example/text-size.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -require __DIR__ . '/../autoload.php'; -use Mike42\Escpos\Printer; -use Mike42\Escpos\PrintConnectors\FilePrintConnector; - -$connector = new FilePrintConnector("php://stdout"); -$printer = new Printer($connector); - -/* Initialize */ -$printer -> initialize(); - -/* Text of various (in-proportion) sizes */ -title($printer, "Change height & width\n"); -for ($i = 1; $i <= 8; $i++) { - $printer -> setTextSize($i, $i); - $printer -> text($i); -} -$printer -> text("\n"); - -/* Width changing only */ -title($printer, "Change width only (height=4):\n"); -for ($i = 1; $i <= 8; $i++) { - $printer -> setTextSize($i, 4); - $printer -> text($i); -} -$printer -> text("\n"); - -/* Height changing only */ -title($printer, "Change height only (width=4):\n"); -for ($i = 1; $i <= 8; $i++) { - $printer -> setTextSize(4, $i); - $printer -> text($i); -} -$printer -> text("\n"); - -/* Very narrow text */ -title($printer, "Very narrow text:\n"); -$printer -> setTextSize(1, 8); -$printer -> text("The quick brown fox jumps over the lazy dog.\n"); - -/* Very flat text */ -title($printer, "Very wide text:\n"); -$printer -> setTextSize(4, 1); -$printer -> text("Hello world!\n"); - -/* Very large text */ -title($printer, "Largest possible text:\n"); -$printer -> setTextSize(8, 8); -$printer -> text("Hello\nworld!\n"); - -$printer -> cut(); -$printer -> close(); - -function title(Printer $printer, $text) -{ - $printer -> selectPrintMode(Printer::MODE_EMPHASIZED); - $printer -> text("\n" . $text); - $printer -> selectPrintMode(); // Reset -} diff --git a/htdocs/includes/mike42/escpos-php/test/bootstrap.php b/htdocs/includes/mike42/escpos-php/test/bootstrap.php deleted file mode 100644 index 749629ac4af..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/bootstrap.php +++ /dev/null @@ -1,40 +0,0 @@ - $c) { - $code = ord($c); - if ($code < 32 || $code > 126) { - $chars[$i] = "\\x" . bin2hex($c); - } - } - return implode($chars); -} diff --git a/htdocs/includes/mike42/escpos-php/test/integration/ExampleTest.php b/htdocs/includes/mike42/escpos-php/test/integration/ExampleTest.php deleted file mode 100644 index 6ba8e23e59e..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/integration/ExampleTest.php +++ /dev/null @@ -1,187 +0,0 @@ - exampleDir = dirname(__FILE__) . "/../../example/"; - } - - /** - * @medium - */ - public function testBitImage() - { - $this->markTestSkipped('Not repeatable on Travis CI.'); - $this -> requireGraphicsLibrary(); - $outp = $this -> runExample("bit-image.php"); - $this -> outpTest($outp, "bit-image.bin"); - } - - /** - * @medium - */ - public function testCharacterEncodings() - { - $outp = $this -> runExample("character-encodings.php"); - $this -> outpTest($outp, "character-encodings.bin"); - } - - /** - * @medium - */ - public function testCharacterTables() - { - $outp = $this -> runExample("character-tables.php"); - $this -> outpTest($outp, "character-tables.bin"); - } - - private function outpTest($outp, $fn) - { - $file = dirname(__FILE__) . "/resources/output/".$fn; - if (!file_exists($file)) { - file_put_contents($file, $outp); - } - $this -> assertEquals($outp, file_get_contents($file)); - } - - /** - * @medium - */ - public function testDemo() - { - $this->markTestSkipped('Not repeatable on Travis CI.'); - $this -> requireGraphicsLibrary(); - $outp = $this -> runExample("demo.php"); - $this -> outpTest($outp, "demo.bin"); - } - - /** - * @medium - */ - public function testGraphics() - { - $this->markTestSkipped('Not repeatable on Travis CI.'); - $this -> requireGraphicsLibrary(); - $outp = $this -> runExample("graphics.php"); - $this -> outpTest($outp, "graphics.bin"); - } - - /** - * @medium - */ - public function testReceiptWithLogo() - { - $this->markTestSkipped('Not repeatable on Travis CI.'); - $this -> requireGraphicsLibrary(); - $outp = $this -> runExample("receipt-with-logo.php"); - $this -> outpTest($outp, "receipt-with-logo.bin"); - } - - /** - * @medium - */ - public function testQrCode() - { - $outp = $this -> runExample("qr-code.php"); - $this -> outpTest($outp, "qr-code.bin"); - } - - /** - * @medium - */ - public function testBarcode() - { - $outp = $this -> runExample("barcode.php"); - $this -> outpTest($outp, "barcode.bin"); - } - - /** - * @medium - */ - public function testTextSize() - { - $outp = $this -> runExample("text-size.php"); - $this -> outpTest($outp, "text-size.bin"); - } - - /** - * @medium - */ - public function testMarginsAndSpacing() - { - $outp = $this -> runExample("margins-and-spacing.php"); - $this -> outpTest($outp, "margins-and-spacing.bin"); - } - - /** - * @medium - */ - public function testPdf417Code() - { - $outp = $this -> runExample("pdf417-code.php"); - $this -> outpTest($outp, "pdf417-code.bin"); - } - - public function testInterfaceCups() - { - $outp = $this -> runSyntaxCheck("interface/cups.php"); - } - - public function testInterfaceEthernet() - { - $outp = $this -> runSyntaxCheck("interface/ethernet.php"); - } - - public function testInterfaceLinuxUSB() - { - $outp = $this -> runSyntaxCheck("interface/linux-usb.php"); - } - - public function testInterfaceWindowsUSB() - { - $outp = $this -> runSyntaxCheck("interface/windows-usb.php"); - } - - public function testInterfaceSMB() - { - $outp = $this -> runSyntaxCheck("interface/smb.php"); - } - - public function testInterfaceWindowsLPT() - { - $outp = $this -> runSyntaxCheck("interface/windows-lpt.php"); - } - - private function runSyntaxCheck($fn) - { - $this -> runExample($fn, true); - } - - private function runExample($fn, $syntaxCheck = false) - { - // Change directory and check script - chdir($this -> exampleDir); - $this -> assertTrue(file_exists($fn), "Script $fn not found."); - // Run command and save output - $php = "php" . ($syntaxCheck ? " -l" : ""); - ob_start(); - passthru($php . " " . escapeshellarg($fn), $retval); - $outp = ob_get_contents(); - ob_end_clean(); - // Check return value - $this -> assertEquals(0, $retval, "Example $fn exited with status $retval"); - return $outp; - } - - protected function requireGraphicsLibrary() - { - if (!EscposImage::isGdLoaded() && !EscposImage::isImagickLoaded()) { - $this -> markTestSkipped("This test requires a graphics library."); - } - } -} diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/barcode.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/barcode.bin deleted file mode 100644 index ae4070d70a0..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/barcode.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/bit-image.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/bit-image.bin deleted file mode 100644 index 462eb1a0bf3..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/bit-image.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/character-encodings.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/character-encodings.bin deleted file mode 100644 index f93ea377722..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/character-encodings.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/character-tables.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/character-tables.bin deleted file mode 100644 index 9979e46bdd5..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/character-tables.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/demo.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/demo.bin deleted file mode 100644 index 6b426d91ff0..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/demo.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/graphics.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/graphics.bin deleted file mode 100644 index 8eeda76d297..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/graphics.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/margins-and-spacing.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/margins-and-spacing.bin deleted file mode 100644 index 0b3a4676033..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/margins-and-spacing.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/pdf417-code.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/pdf417-code.bin deleted file mode 100644 index ab2d7c54958..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/pdf417-code.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/qr-code.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/qr-code.bin deleted file mode 100644 index a1e687f151c..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/qr-code.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/receipt-with-logo.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/receipt-with-logo.bin deleted file mode 100644 index a4ed9c35304..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/receipt-with-logo.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/text-size.bin b/htdocs/includes/mike42/escpos-php/test/integration/resources/output/text-size.bin deleted file mode 100644 index 4d36038e463..00000000000 Binary files a/htdocs/includes/mike42/escpos-php/test/integration/resources/output/text-size.bin and /dev/null differ diff --git a/htdocs/includes/mike42/escpos-php/test/unit/AuresCustomerDisplayTest.php b/htdocs/includes/mike42/escpos-php/test/unit/AuresCustomerDisplayTest.php deleted file mode 100644 index c0f803afa97..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/unit/AuresCustomerDisplayTest.php +++ /dev/null @@ -1,76 +0,0 @@ - outputConnector = new DummyPrintConnector(); - $profile = CapabilityProfile::load('OCD-300'); - $this -> printer = new AuresCustomerDisplay($this -> outputConnector, $profile); - } - - protected function checkOutput($expected = null) - { - /* Check those output strings */ - $outp = $this -> outputConnector -> getData(); - if ($expected === null) { - echo "\nOutput was:\n\"" . friendlyBinary($outp) . "\"\n"; - } - $this -> assertEquals($expected, $outp); - } - - protected function tearDown() - { - $this -> outputConnector -> finalize(); - } - - public function testInitializeOutput() - { - $this -> checkOutput("\x02\x05C1\x03\x1b@\x1bt\x00\x1f\x02"); - } - - public function testselectTextScrollMode() { - $this -> outputConnector -> clear(); - $this -> printer -> selectTextScrollMode(AuresCustomerDisplay::TEXT_OVERWRITE); - $this -> checkOutput("\x1f\x01"); - } - - public function testClear() { - $this -> outputConnector -> clear(); - $this -> printer -> clear(); - $this -> checkOutput("\x0c"); - } - - public function testShowFirmwareVersion() { - $this -> outputConnector -> clear(); - $this -> printer -> showFirmwareVersion(); - $this -> checkOutput("\x02\x05V\x01\x03"); - } - - public function testSelfTest() { - $this -> outputConnector -> clear(); - $this -> printer -> selfTest(); - $this -> checkOutput("\x02\x05D\x08\x03"); - } - - public function testShowLogo() { - $this -> outputConnector -> clear(); - $this -> printer -> showLogo(); - $this -> checkOutput("\x02\xfcU\xaaU\xaa"); - } - - public function testTest() { - $this -> outputConnector -> clear(); - // Handling of line-endings differs to regular printers, need to use \r\n - $this -> printer -> text("Hello\nWorld\n"); - $this -> checkOutput("Hello\x0d\x0aWorld\x0d\x0a"); - } -} \ No newline at end of file diff --git a/htdocs/includes/mike42/escpos-php/test/unit/CapabilityProfileTest.php b/htdocs/includes/mike42/escpos-php/test/unit/CapabilityProfileTest.php deleted file mode 100644 index 923811e7042..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/unit/CapabilityProfileTest.php +++ /dev/null @@ -1,59 +0,0 @@ -assertFalse(array_search('simple', $names) === false); - $this->assertFalse(array_search('default', $names) === false); - $this->assertTrue(array_search('lalalalala', $names) === false); - } - - public function testLoadDefault() - { - // Just load the default profile and check it out - $profile = CapabilityProfile::load('default'); - $this->assertEquals("default", $profile->getId()); - $this->assertEquals("Default", $profile->getName()); - $this->assertTrue($profile->getSupportsBarcodeB()); - $this->assertTrue($profile->getSupportsBitImageRaster()); - $this->assertTrue($profile->getSupportsGraphics()); - $this->assertTrue($profile->getSupportsQrCode()); - $this->assertTrue($profile->getSupportsPdf417Code()); - $this->assertFalse($profile->getSupportsStarCommands()); - $this->assertArrayHasKey('0', $profile->getCodePages()); - } - - public function testCodePageCacheKey() - { - $default = CapabilityProfile::load('default'); - $simple = CapabilityProfile::load('simple'); - $this->assertNotEquals($default->getCodePageCacheKey(), $simple->getCodePageCacheKey()); - } - - public function testBadProfileNameSuggestion() - { - $this->setExpectedException('\InvalidArgumentException', 'simple'); - $profile = CapabilityProfile::load('simpel'); - } - - public function testBadFeatureNameSuggestion() - { - $this->setExpectedException('\InvalidArgumentException', 'graphics'); - $profile = CapabilityProfile::load('default'); - $profile->getFeature('graphicx'); - } - - public function testSuggestions() - { - $input = "orangee"; - $choices = array("apple", "orange", "pear"); - $suggestions = CapabilityProfile::suggestNearest($input, $choices, 1); - $this->assertEquals(1, count($suggestions)); - $this->assertEquals("orange", $suggestions[0]); - } -} \ No newline at end of file diff --git a/htdocs/includes/mike42/escpos-php/test/unit/CodePageTest.php b/htdocs/includes/mike42/escpos-php/test/unit/CodePageTest.php deleted file mode 100644 index 0e7b661f94d..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/unit/CodePageTest.php +++ /dev/null @@ -1,63 +0,0 @@ -markTestSkipped("Requires iconv"); - } - } - - public function testDataIconv() - { - // Set up CP437 - $this->requiresIconv(); - $cp = new CodePage("CP437", array( - "name" => "CP437", - "iconv" => "CP437" - )); - $this->assertTrue($cp->isEncodable()); - $this->assertEquals($cp->getIconv(), "CP437"); - $this->assertEquals($cp->getName(), "CP437"); - $this->assertEquals($cp->getId(), "CP437"); - $this->assertEquals($cp->getNotes(), null); - // Get data and see if it's right - $data = $cp->getData(); - $expected = "ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "; - $this->assertEquals($expected, $data); - } - - public function testDataIconvBogus() - { - // No errors raised, you just get an empty list of supported characters if you try to compute a fake code page - $this->requiresIconv(); - $cp = new CodePage("foo", array( - "name" => "foo", - "iconv" => "foo" - )); - $this->assertTrue($cp->isEncodable()); - $this->assertEquals($cp->getIconv(), "foo"); - $this->assertEquals($cp->getName(), "foo"); - $this->assertEquals($cp->getId(), "foo"); - $this->assertEquals($cp->getNotes(), null); - $data = $cp->getData(); - $expected = str_repeat(" ", 128); - $this->assertEquals($expected, $data); - // Do this twice (caching behaviour) - $data = $cp->getData(); - $this->assertEquals($expected, $data); - } - - public function testDataCannotEncode() - { - $this->setExpectedException('\InvalidArgumentException'); - $cp = new CodePage("foo", array( - "name" => "foo" - )); - $this->assertFalse($cp->isEncodable()); - $cp->getData(); - } -} \ No newline at end of file diff --git a/htdocs/includes/mike42/escpos-php/test/unit/CupsPrintConnectorTest.php b/htdocs/includes/mike42/escpos-php/test/unit/CupsPrintConnectorTest.php deleted file mode 100644 index 41499ee4b27..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/unit/CupsPrintConnectorTest.php +++ /dev/null @@ -1,36 +0,0 @@ -getMockConnector("FooPrinter", array("FooPrinter")); - $connector->expects($this->once())->method('getCmdOutput')->with($this->stringContains("lp -d 'FooPrinter' ")); - $connector->finalize(); - } - public function testPrinterDoesntExist() - { - $this -> setExpectedException('BadMethodCallException'); - $connector = $this->getMockConnector("FooPrinter", array("OtherPrinter")); - $connector->expects($this->once())->method('getCmdOutput')->with($this->stringContains("lp -d 'FooPrinter' ")); - $connector->finalize(); - } - public function testNoPrinter() - { - $this -> setExpectedException('BadMethodCallException'); - $connector = $this->getMockConnector("FooPrinter", array("")); - } - private function getMockConnector($path, array $printers) - { - $stub = $this->getMockBuilder('Mike42\Escpos\PrintConnectors\CupsPrintConnector')->setMethods(array ( - 'getCmdOutput', - 'getLocalPrinters' - ))->disableOriginalConstructor()->getMock(); - $stub->method('getCmdOutput')->willReturn(""); - $stub->method('getLocalPrinters')->willReturn($printers); - $stub->__construct($path); - return $stub; - } -} diff --git a/htdocs/includes/mike42/escpos-php/test/unit/EscposImageTest.php b/htdocs/includes/mike42/escpos-php/test/unit/EscposImageTest.php deleted file mode 100644 index 08e1be91c50..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/unit/EscposImageTest.php +++ /dev/null @@ -1,16 +0,0 @@ - setExpectedException('Exception'); - $img = EscposImage::load('not-a-real-file.png'); - } - public function testImageNotSupportedException() - { - $this -> setExpectedException('InvalidArgumentException'); - $img = EscposImage::load('/dev/null', false, array()); - } -} \ No newline at end of file diff --git a/htdocs/includes/mike42/escpos-php/test/unit/EscposPrintBufferTest.php b/htdocs/includes/mike42/escpos-php/test/unit/EscposPrintBufferTest.php deleted file mode 100644 index af0ee2b9b73..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/unit/EscposPrintBufferTest.php +++ /dev/null @@ -1,192 +0,0 @@ - outputConnector = new DummyPrintConnector(); - $printer = new Printer($this -> outputConnector); - $this -> buffer = $printer -> getPrintBuffer(); - } - - protected function checkOutput($expected = null) - { - /* Check those output strings */ - $outp = $this -> outputConnector -> getData(); - if ($expected === null) { - echo "\nOutput was:\n\"" . friendlyBinary($outp) . "\"\n"; - } - $this -> assertEquals($expected, $outp); - } - - protected function tearDown() - { - $this -> outputConnector -> finalize(); - } - - public function testRawTextNonprintable() - { - $this -> buffer -> writeTextRaw("Test" . Printer::ESC . "v1\n"); - $this -> checkOutput("\x1b@Test?v1\x0a"); // ASCII ESC character is substituted for '?' - } - - public function testDanish() - { - $this -> buffer -> writeText("Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Wolther spillede på xylofon.\n"); - $this -> checkOutput("\x1b@Quizdeltagerne spiste jordb\x91r med fl\x1bt\x02\x9bde, mens cirkusklovnen Wolther spillede p\x86 xylofon.\x0a"); - } - - public function testGerman() - { - $this -> buffer -> writeText("Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.\n"); - $this -> checkOutput("\x1b@Falsches \x9aben von Xylophonmusik qu\x84lt jeden gr\x94\xe1eren Zwerg.\x0a"); - } - - public function testGreek() - { - $this -> buffer -> writeText("Ξεσκεπάζω την ψυχοφθόρα βδελυγμία"); - $this -> checkOutput("\x1b@\x1bt\x0e\x8d\x9c\xa9\xa1\x9c\xa7\xe1\x9d\xe0 \xab\x9e\xa4 \xaf\xac\xae\xa6\xad\x9f\xe6\xa8\x98 \x99\x9b\x9c\xa2\xac\x9a\xa3\xe5\x98"); - } - - public function testGreekWithDiacritics() - { - // This is a string which is known to be un-printable in ESC/POS (the grave-accented letters are not in any code page), - // so we are checking the substitution '?' for unknown characters. - $this -> buffer -> writeText("Γαζέες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο.\n"); - $this -> checkOutput("\x1b@\xe2\xe0\x1bt\x0e\x9d\xe2\x9c\xaa \xa1\x98? \xa3\xac\xa8\xab\xa0?\xaa \x9b?\xa4 \x9f? \x99\xa8? \xa7\xa0? \xa9\xab? \xae\xa8\xac\xa9\x98\xad? \xa5\xe2\xad\xe0\xab\xa6.\x0a"); - } - - public function testEnglish() - { - $this -> buffer -> writeText("The quick brown fox jumps over the lazy dog.\n"); - $this -> checkOutput("\x1b@The quick brown fox jumps over the lazy dog.\n"); - } - - public function testSpanish() - { - // This one does not require changing code-pages at all, so characters are just converted from Unicode to CP437. - $this -> buffer -> writeText("El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro.\n"); - $this -> checkOutput("\x1b@El ping\x81ino Wenceslao hizo kil\xa2metros bajo exhaustiva lluvia y fr\xa1o, a\xa4oraba a su querido cachorro.\x0a"); - } - - public function testFrench() - { - $this -> buffer -> writeText("Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en canoë au delà des îles, près du mälström où brûlent les novæ.\n"); - $this -> checkOutput("\x1b@Le c\x1bt\x10\x9cur d\xe9\xe7u mais l'\xe2me plut\xf4t na\xefve, Lou\xffs r\xeava de crapa\xfcter en cano\xeb au del\xe0 des \xeeles, pr\xe8s du m\xe4lstr\xf6m o\xf9 br\xfblent les nov\xe6.\x0a"); - } - - public function testIrishGaelic() - { - // Note that some letters with diacritics cannot be printed for Irish Gaelic text, so text may need to be simplified. - $this -> buffer -> writeText("D'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava agus Ádhaimh.\n"); - $this -> checkOutput("\x1b@D'fhuascail \x1bt\x02\xd6osa, \xe9rmhac na h\xe0ighe Beannaithe, p\xa2r \x90ava agus \xb5dhaimh.\x0a"); - } - - public function testHungarian() - { - $this -> buffer -> writeText("Árvíztűrő tükörfúrógép.\n"); - $this -> checkOutput("\x1b@\x1bt\x02\xb5rv\xa1zt\x1bt\x12\xfbr\x8b t\x81k\x94rf\xa3r\xa2g\x82p.\x0a"); - } - - public function testIcelandic() - { - $this -> buffer -> writeText("Kæmi ný öxi hér ykist þjófum nú bæði víl og ádrepa."); - $this -> checkOutput("\x1b@K\x91mi n\x1bt\x02\xec \x94xi h\x82r ykist \xe7j\xa2fum n\xa3 b\x91\xd0i v\xa1l og \xa0drepa."); - } - - public function testJapaneseHiragana() - { - $this -> markTestIncomplete("Non-ASCII character sets not yet supported."); - $this -> buffer -> writeText(implode("\n", array("いろはにほへとちりぬるを", " わかよたれそつねならむ", "うゐのおくやまけふこえて", "あさきゆめみしゑひもせす")) . "\n"); - $this -> checkOutput(); - } - - public function testJapaneseKatakana() - { - $this -> markTestIncomplete("Non-ASCII character sets not yet supported."); - $this -> buffer -> writeText(implode("\n", array("イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム", "ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン")) . "\n"); - $this -> checkOutput("\x1b@\x1bt\x01\xb2\xdb\xca\xc6\xce\xcd\xc4 \xc1\xd8\xc7\xd9\xa6 \xdc\xb6\xd6\xc0\xda\xbf \xc2\xc8\xc5\xd7\xd1\x0a\xb3\xb2\xc9\xb5\xb8\xd4\xcf \xb9\xcc\xba\xb4\xc3 \xb1\xbb\xb7\xd5\xd2\xd0\xbc \xb4\xcb\xd3\xbe\xbd\xdd\x0a"); - } - - public function testJapaneseKataKanaHalfWidth() - { - $this -> buffer -> writeText(implode("\n", array("イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム", "ウイノオクヤマ ケフコエテ アサキユメミシ エヒモセスン")) . "\n"); - $this -> checkOutput("\x1b@\x1bt\x01\xb2\xdb\xca\xc6\xce\xcd\xc4 \xc1\xd8\xc7\xd9\xa6 \xdc\xb6\xd6\xc0\xda\xbf \xc2\xc8\xc5\xd7\xd1\x0a\xb3\xb2\xc9\xb5\xb8\xd4\xcf \xb9\xcc\xba\xb4\xc3 \xb1\xbb\xb7\xd5\xd2\xd0\xbc \xb4\xcb\xd3\xbe\xbd\xdd\x0a"); - } - - public function testLatvian() - { - $this -> buffer -> writeText("Glāžšķūņa rūķīši dzērumā čiepj Baha koncertflīģeļu vākus.\n"); - $this -> checkOutput("\x1b@Gl\x1bt!\x83\xd8\xd5\xe9\xd7\xeca r\xd7\xe9\x8c\xd5i dz\x89rum\x83 \xd1iepj Baha koncertfl\x8c\x85e\xebu v\x83kus.\x0a"); - } - - public function testPolish() - { - $this -> buffer -> writeText("Pchnąć w tę łódź jeża lub ośm skrzyń fig.\n"); - $this -> checkOutput("\x1b@Pchn\x1bt\x12\xa5\x86 w t\xa9 \x88\xa2d\xab je\xbea lub o\x98m skrzy\xe4 fig.\x0a"); - } - - public function testRussian() - { - $this -> buffer -> writeText("В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!\n"); - $this -> checkOutput("\x1b@\x1bt\x11\x82 \xe7\xa0\xe9\xa0\xe5 \xee\xa3\xa0 \xa6\xa8\xab \xa1\xeb \xe6\xa8\xe2\xe0\xe3\xe1? \x84\xa0, \xad\xae \xe4\xa0\xab\xec\xe8\xa8\xa2\xeb\xa9 \xed\xaa\xa7\xa5\xac\xaf\xab\xef\xe0!\x0a"); - } - - public function testThai() - { - $this -> markTestIncomplete("Non-ASCII character sets not yet supported."); - $this -> buffer -> writeText("นายสังฆภัณฑ์ เฮงพิทักษ์ฝั่ง ผู้เฒ่าซึ่งมีอาชีพเป็นฅนขายฃวด ถูกตำรวจปฏิบัติการจับฟ้องศาล ฐานลักนาฬิกาคุณหญิงฉัตรชฎา ฌานสมาธิ\n"); // Quotation from Wikipedia - $this -> checkOutput(); - } - - public function testTurkish() - { - $this -> buffer -> writeText("Pijamalı hasta, yağız şoföre çabucak güvendi.\n"); - $this -> checkOutput("\x1b@Pijamal\x1bt\x02\xd5 hasta, ya\x1bt\x0d\xa7\x8dz \x9fof\x94re \x87abucak g\x81vendi.\x0a"); - } - - public function testArabic() - { - $this -> markTestIncomplete("Right-to-left text not yet supported."); - $this -> buffer -> writeText("صِف خَلقَ خَودِ كَمِثلِ الشَمسِ إِذ بَزَغَت — يَحظى الضَجيعُ بِها نَجلاءَ مِعطارِ" . "\n"); // Quotation from Wikipedia - $this -> checkOutput(); - } - - public function testHebrew() - { - // RTL text is more complex than the above. - $this -> markTestIncomplete("Right-to-left text not yet supported."); - $this -> buffer -> writeText("דג סקרן שט בים מאוכזב ולפתע מצא לו חברה איך הקליטה" . "\n"); - $this -> checkOutput(); - } - - public function testVietnamese() { - $this -> buffer -> writeText("Tiếng Việt, còn gọi tiếng Việt Nam hay Việt ngữ, là ngôn ngữ của người Việt (người Kinh) và là ngôn ngữ chính thức tại Việt Nam.\n"); - $this -> checkOutput("\x1b@Ti\x1bt\x1e\xd5ng Vi\xd6t, c\xdfn g\xe4i ti\xd5ng Vi\xd6t Nam hay Vi\xd6t ng\xf7, l\xb5 ng\xabn ng\xf7 c\xf1a ng\xad\xeai Vi\xd6t (ng\xad\xeai Kinh) v\xb5 l\xb5 ng\xabn ng\xf7 ch\xddnh th\xf8c t\xb9i Vi\xd6t Nam.\x0a"); - } - - public function testWindowsLineEndings() { - $this -> buffer -> writeText("Hello World!\r\n"); - $this -> checkOutput("\x1b@Hello World!\x0a"); - } - - public function testWindowsLineEndingsRaw() { - $this -> buffer -> writeTextRaw("Hello World!\r\n"); - $this -> checkOutput("\x1b@Hello World!\x0a"); - } -} diff --git a/htdocs/includes/mike42/escpos-php/test/unit/EscposTest.php b/htdocs/includes/mike42/escpos-php/test/unit/EscposTest.php deleted file mode 100644 index 0b70e96b370..00000000000 --- a/htdocs/includes/mike42/escpos-php/test/unit/EscposTest.php +++ /dev/null @@ -1,1127 +0,0 @@ - outputConnector = new DummyPrintConnector(); - $this -> printer = new Printer($this -> outputConnector); - } - - protected function checkOutput($expected = null) - { - /* Check those output strings */ - $outp = $this -> outputConnector -> getData(); - if ($expected === null) { - echo "\nOutput was:\n\"" . friendlyBinary($outp) . "\"\n"; - } - $this -> assertEquals($expected, $outp); - } - - protected function tearDown() - { - $this -> outputConnector -> finalize(); - } - - protected function requireGraphicsLibrary() - { - if (!EscposImage::isGdLoaded() && !EscposImage::isImagickLoaded()) { - // If the test is about to do something which requires a library, - // something must throw an exception. - $this -> setExpectedException('Exception'); - } - } - - public function testInitializeOutput() - { - $this -> checkOutput("\x1b\x40"); - } - - public function testTextStringOutput() - { - $this -> printer -> text("The quick brown fox jumps over the lazy dog\n"); - $this -> checkOutput("\x1b@The quick brown fox jumps over the lazy dog\n"); - } - - public function testTextDefault() - { - $this -> printer -> text(); - $this -> checkOutput("\x1b@"); - } - - public function testTextChinese() - { - // Switch to chinese print mode, GBK output, switch back to alphanumeric. - $this -> printer -> textChinese("示例文本打印机!\n"); - $this -> checkOutput("\x1b@\x1c&\xca\xbe\xc0\xfd\xce\xc4\xb1\xbe\xb4\xf2\xd3\xa1\xbb\xfa!\x0a\x1c."); - } - - public function testTextRaw() - { - // Under raw output, the raw bytes are sent to the printer, so typing a UTF-8 euro literally causes \xE2 \x82 \xAC to be sent. - // Under text(), this would cause a code-page change (to a page that contains a Euro symbol), and single byte. - $this -> printer -> textRaw("€\n"); - $this -> checkOutput("\x1b@\xe2\x82\xac\x0a"); - } - - public function testTextString() - { - $this -> printer -> text("String"); - $this -> printer -> text(123); - $this -> printer -> text(); - $this -> printer -> text(null); - $this -> printer -> text(1.2); - $this -> printer -> text(new FooBar("FooBar")); - $this -> checkOutput("\x1b@String1231.2FooBar"); - } - - public function testTextObject() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> text(new DateTime()); - } - - public function testFeedDefault() - { - $this -> printer -> feed(); - $this -> checkOutput("\x1b@\x0a"); - } - - public function testFeed3Lines() - { - $this -> printer -> feed(3); - $this -> checkOutput("\x1b@\x1bd\x03"); - } - - public function testFeedZero() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> feed(0); - } - - public function testFeedNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> feed("ab"); - } - - public function testFeedTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> feed(256); - } - - /* Print mode */ - public function testSelectPrintModeDefault() - { - $this -> printer -> selectPrintMode(); - $this -> checkOutput("\x1b@\x1b!\x00"); - } - - public function testSelectPrintModeAcceptedValues() - { - /* This iterates over a bunch of numbers, figures out which - ones contain invalid flags, and checks that the driver - rejects those, but accepts the good inputs */ - - for ($i = -1; $i <= 256; $i++) { - $invalid = ($i < 0) || ($i > 255) || (($i & 2) == 2) || (($i & 4) == 4) || (($i & 64) == 64); - $failed = false; - try { - $this -> printer -> selectPrintMode($i); - } catch (Exception $e) { - $failed = true; - } - $this -> assertEquals($failed, $invalid); - } - } - - /* Underline */ - public function testSetUnderlineDefault() - { - $this -> printer -> setUnderline(); - $this -> checkOutput("\x1b@\x1b-\x01"); - } - - public function testSetUnderlineOff() - { - $this -> printer -> setUnderline(Printer::UNDERLINE_NONE); - $this -> checkOutput("\x1b@\x1b-\x00"); - } - - public function testSetUnderlineOn() - { - $this -> printer -> setUnderline(Printer::UNDERLINE_SINGLE); - $this -> checkOutput("\x1b@\x1b-\x01"); - } - - public function testSetUnderlineDbl() - { - $this -> printer -> setUnderline(Printer::UNDERLINE_DOUBLE); - $this -> checkOutput("\x1b@\x1b-\x02"); - } - - public function testSetUnderlineAcceptedValues() - { - $this -> printer -> setUnderline(0); - $this -> printer -> setUnderline(1); - $this -> printer -> setUnderline(2); - /* These map to 0 & 1 for interchangeability with setEmphasis */ - $this -> printer -> setUnderline(true); - $this -> printer -> setUnderline(false); - $this -> checkOutput("\x1b@\x1b-\x00\x1b-\x01\x1b-\x02\x1b-\x01\x1b-\x00"); - } - - public function testSetUnderlineTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setUnderline(3); - } - - public function testSetUnderlineNegative() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setUnderline(-1); - } - - public function testSetUnderlineNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setUnderline("Hello"); - } - - /* Emphasis */ - public function testSetEmphasisDefault() - { - $this -> printer -> setEmphasis(); - $this -> checkOutput("\x1b@\x1bE\x01"); - } - - public function testSetEmphasisOn() - { - $this -> printer -> setEmphasis(true); - $this -> checkOutput("\x1b@\x1bE\x01"); - } - - public function testSetEmphasisOff() - { - $this -> printer -> setEmphasis(false); - $this -> checkOutput("\x1b@\x1bE\x00"); - } - - public function testSetEmphasisNonBoolean() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setEmphasis(7); - } - - /* Double strike */ - public function testSetDoubleStrikeDefault() - { - $this -> printer -> setDoubleStrike(); - $this -> checkOutput("\x1b@\x1bG\x01"); - } - - public function testSetDoubleStrikeOn() - { - $this -> printer -> setDoubleStrike(true); - $this -> checkOutput("\x1b@\x1bG\x01"); - } - - public function testSetDoubleStrikeOff() - { - $this -> printer -> setDoubleStrike(false); - $this -> checkOutput("\x1b@\x1bG\x00"); - } - - public function testSetDoubleStrikeNonBoolean() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setDoubleStrike(4); - } - - /* Font */ - public function testSetFontDefault() - { - $this -> printer -> setFont(); - $this -> checkOutput("\x1b@\x1bM\x00"); - } - - public function testSetFontAcceptedValues() - { - $this -> printer -> setFont(Printer::FONT_A); - $this -> printer -> setFont(Printer::FONT_B); - $this -> printer -> setFont(Printer::FONT_C); - $this -> checkOutput("\x1b@\x1bM\x00\x1bM\x01\x1bM\x02"); - } - - public function testSetFontNegative() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setFont(-1); - } - - - public function testSetFontTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setFont(3); - } - - public function testSetFontNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setFont('hello'); - } - - /* Justification */ - public function testSetJustificationDefault() - { - $this -> printer -> setJustification(); - $this -> checkOutput("\x1b@\x1ba\x00"); - } - - public function testSetJustificationLeft() - { - $this -> printer -> setJustification(Printer::JUSTIFY_LEFT); - $this -> checkOutput("\x1b@\x1ba\x00"); - } - - public function testSetJustificationRight() - { - $this -> printer -> setJustification(Printer::JUSTIFY_RIGHT); - $this -> checkOutput("\x1b@\x1ba\x02"); - } - - public function testSetJustificationCenter() - { - $this -> printer -> setJustification(Printer::JUSTIFY_CENTER); - $this -> checkOutput("\x1b@\x1ba\x01"); - } - - public function testSetJustificationNegative() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setJustification(-1); - } - - - public function testSetJustificationTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setFont(3); - } - - public function testSetJustificationNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setJustification('hello'); - } - - /* Reverse feed */ - public function testFeedReverseDefault() - { - $this -> printer -> feedReverse(); - $this -> checkOutput("\x1b@\x1be\x01"); - } - - public function testFeedReverse3() - { - $this -> printer -> feedReverse(3); - $this -> checkOutput("\x1b@\x1be\x03"); - } - - public function testFeedReverseNegative() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> feedReverse(-1); - } - - public function testFeedReverseTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> feedReverse(256); - } - - public function testFeedReverseNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> feedReverse('hello'); - } - - /* Cut */ - public function testCutDefault() - { - // TODO check what the accepted range of values should be for $line - // cut($mode = self::CUT_FULL, $lines = 3) - $this -> printer -> cut(); - $this -> checkOutput("\x1b@\x1dVA\x03"); - } - - /* Set barcode height */ - public function testSetBarcodeHeightDefault() - { - $this -> printer -> setBarcodeHeight(); - $this -> checkOutput("\x1b@\x1dh\x08"); - } - - public function testBarcodeHeight10() - { - $this -> printer -> setBarcodeHeight(10); - $this -> checkOutput("\x1b@\x1dh\x0a"); - } - - public function testSetBarcodeHeightNegative() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeHeight(-1); - } - - public function testSetBarcodeHeightTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeHeight(256); - } - - public function testSetBarcodeHeightNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeHeight('hello'); - } - - /* Set barcode width */ - public function testSetBarcodeWidthDefault() - { - $this -> printer -> setBarcodeWidth(); - $this -> checkOutput("\x1b@\x1dw\x03"); - } - - public function testBarcodeWidth1() - { - $this -> printer -> setBarcodeWidth(1); - $this -> checkOutput("\x1b@\x1dw\x01"); - } - - public function testSetBarcodeWidthNegative() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeWidth(-1); - } - - public function testSetBarcodeWidthTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeWidth(256); - } - - public function testSetBarcodeWidthNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeWidth('hello'); - } - - /* Barcode text position */ - public function testSetBarcodeTextPositionDefault() - { - $this -> printer -> setBarcodeTextPosition(); - $this -> checkOutput("\x1b@\x1dH\x00"); - } - - public function testSetBarcodeTextPositionBelow() - { - $this -> printer -> setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW); - $this -> checkOutput("\x1b@\x1dH\x02"); - } - - public function testSetBarcodeTextPositionBoth() - { - $this -> printer -> setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW | Printer::BARCODE_TEXT_ABOVE); - $this -> checkOutput("\x1b@\x1dH\x03"); - } - - public function testSetBarcodeTextPositionNegative() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeTextPosition(-1); - } - - public function testSetBarcodeTextPositionTooLarge() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeTextPosition(4); - } - - public function tesSetBarcodeTextPositionNonInteger() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> setBarcodeTextPosition('hello'); - } - - /* Barcode - UPC-A */ - public function testBarcodeUpcaNumeric11Char() - { - $this -> printer -> barcode("01234567890", Printer::BARCODE_UPCA); - $this -> checkOutput("\x1b@\x1dkA\x0b01234567890"); - } - - public function testBarcodeUpcaNumeric12Char() - { - $this -> printer -> barcode("012345678901", Printer::BARCODE_UPCA); - $this -> checkOutput("\x1b@\x1dkA\x0c012345678901"); - } - - public function testBarcodeUpcaNumeric13Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("0123456789012", Printer::BARCODE_UPCA); - } - - public function testBarcodeUpcaNonNumeric12Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("A12345678901", Printer::BARCODE_UPCA); - } - - /* Barcode - UPC-E */ - public function testBarcodeUpceNumeric6Char() - { - $this -> printer -> barcode("123456", Printer::BARCODE_UPCE); - $this -> checkOutput("\x1b@\x1dkB\x06123456"); - } - - public function testBarcodeUpceNumeric7Char() - { - $this -> printer -> barcode("0123456", Printer::BARCODE_UPCE); - $this -> checkOutput("\x1b@\x1dkB\x070123456"); - } - - public function testBarcodeUpceNumeric8Char() - { - $this -> printer -> barcode("01234567", Printer::BARCODE_UPCE); - $this -> checkOutput("\x1b@\x1dkB\x0801234567"); - } - - public function testBarcodeUpceNumeric11Char() - { - $this -> printer -> barcode("01234567890", Printer::BARCODE_UPCE); - $this -> checkOutput("\x1b@\x1dkB\x0b01234567890"); - } - - public function testBarcodeUpceNumeric12Char() - { - $this -> printer -> barcode("012345678901", Printer::BARCODE_UPCE); - $this -> checkOutput("\x1b@\x1dkB\x0c012345678901"); - } - - public function testBarcodeUpceNumeric9Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("012345678", Printer::BARCODE_UPCE); - } - - public function testBarcodeUpceNonNumeric12Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("A12345678901", Printer::BARCODE_UPCE); - } - - /* Barcode - JAN13 */ - public function testBarcodeJan13Numeric12Char() - { - $this -> printer -> barcode("012345678901", Printer::BARCODE_JAN13); - $this -> checkOutput("\x1b@\x1dkC\x0c012345678901"); - } - - public function testBarcodeJan13Numeric13Char() - { - $this -> printer -> barcode("0123456789012", Printer::BARCODE_JAN13); - $this -> checkOutput("\x1b@\x1dkC\x0d0123456789012"); - } - - public function testBarcodeJan13Numeric11Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("01234567890", Printer::BARCODE_JAN13); - } - - public function testBarcodeJan13NonNumeric13Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("A123456789012", Printer::BARCODE_JAN13); - } - - /* Barcode - JAN8 */ - public function testBarcodeJan8Numeric7Char() - { - $this -> printer -> barcode("0123456", Printer::BARCODE_JAN8); - $this -> checkOutput("\x1b@\x1dkD\x070123456"); - } - - public function testBarcodeJan8Numeric8Char() - { - $this -> printer -> barcode("01234567", Printer::BARCODE_JAN8); - $this -> checkOutput("\x1b@\x1dkD\x0801234567"); - } - - public function testBarcodeJan8Numeric9Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("012345678", Printer::BARCODE_JAN8); - } - - public function testBarcodeJan8NonNumeric8Char() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("A1234567", Printer::BARCODE_JAN8); - } - - /* Barcode - Code39 */ - public function testBarcodeCode39AsDefault() - { - $this -> printer -> barcode("1234"); - $this -> checkOutput("\x1b@\x1dkE\x041234"); - } - - public function testBarcodeCode39Text() - { - $this -> printer -> barcode("ABC 012", Printer::BARCODE_CODE39); - $this -> checkOutput("\x1b@\x1dkE\x07ABC 012"); - } - - public function testBarcodeCode39SpecialChars() - { - $this -> printer -> barcode("$%+-./", Printer::BARCODE_CODE39); - $this -> checkOutput("\x1b@\x1dkE\x06$%+-./"); - } - - public function testBarcodeCode39Asterisks() - { - $this -> printer -> barcode("*TEXT*", Printer::BARCODE_CODE39); - $this -> checkOutput("\x1b@\x1dkE\x06*TEXT*"); - } - - public function testBarcodeCode39AsterisksUnmatched() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("*TEXT", Printer::BARCODE_CODE39); - } - - public function testBarcodeCode39AsteriskInText() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("12*34", Printer::BARCODE_CODE39); - } - - public function testBarcodeCode39Lowercase() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("abcd", Printer::BARCODE_CODE39); - } - - public function testBarcodeCode39Empty() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("**", Printer::BARCODE_CODE39); - } - - /* Barcode - ITF */ - public function testBarcodeItfNumericEven() - { - $this -> printer -> barcode("1234", Printer::BARCODE_ITF); - $this -> checkOutput("\x1b@\x1dkF\x041234"); - } - - public function testBarcodeItfNumericOdd() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("123", Printer::BARCODE_ITF); - } - - public function testBarcodeItfNonNumericEven() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("A234", Printer::BARCODE_ITF); - } - - /* Barcode - Codabar */ - public function testBarcodeCodabarNumeric() - { - $this -> printer -> barcode("A012345A", Printer::BARCODE_CODABAR); - $this -> checkOutput("\x1b@\x1dkG\x08A012345A"); - } - - public function testBarcodeCodabarSpecialChars() - { - $this -> printer -> barcode("A012$+-./:A", Printer::BARCODE_CODABAR); - $this -> checkOutput("\x1b@\x1dkG\x0bA012$+-./:A"); - } - - public function testBarcodeCodabarNotWrapped() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("012345", Printer::BARCODE_CODABAR); - } - - public function testBarcodeCodabarStartStopWrongPlace() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("012A45", Printer::BARCODE_CODABAR); - } - - /* Barcode - Code93 */ - public function testBarcodeCode93Valid() - { - $this -> printer -> barcode("012abcd", Printer::BARCODE_CODE93); - $this -> checkOutput("\x1b@\x1dkH\x07012abcd"); - } - - public function testBarcodeCode93Empty() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("", Printer::BARCODE_CODE93); - } - - /* Barcode - Code128 */ - public function testBarcodeCode128ValidA() - { - $this -> printer -> barcode("{A" . "012ABCD", Printer::BARCODE_CODE128); - $this -> checkOutput("\x1b@\x1dkI\x09{A012ABCD"); - } - - public function testBarcodeCode128ValidB() - { - $this -> printer -> barcode("{B" . "012ABCDabcd", Printer::BARCODE_CODE128); - $this -> checkOutput("\x1b@\x1dkI\x0d{B012ABCDabcd"); - } - - public function testBarcodeCode128ValidC() - { - $this -> printer -> barcode("{C" . chr(21) . chr(32) . chr(43), Printer::BARCODE_CODE128); - $this -> checkOutput("\x1b@\x1dkI\x05{C\x15 +"); - } - - public function testBarcodeCode128NoCodeSet() - { - $this -> setExpectedException('InvalidArgumentException'); - $this -> printer -> barcode("ABCD", Printer::BARCODE_CODE128); - } - - /* Pulse */ - function testPulseDefault() - { - $this -> printer -> pulse(); - $this -> checkOutput("\x1b@\x1bp0