close() публичный Метод

Close the underlying buffer. With some connectors, the job will not actually be sent to the printer until this is called.
public close ( )
 function testText()
 {
     /* Smoke test over text rendering with each profile.
      * Just makes sure we can attempt to print 'hello world' and a non-ASCII
      * char without anything blowing up */
     foreach ($this->checklist as $obj) {
         $connector = new DummyPrintConnector();
         $printer = new Printer($connector, $obj);
         $printer->text("Hello world €\n");
         $printer->close();
         // Check for character cache
         $profileName = $obj->getId();
         $expected = "Characters-{$profileName}.ser.z";
         $filename = __DIR__ . "/../../src/Mike42/Escpos/PrintBuffers/cache/{$expected}";
         $this->assertFileExists($filename);
     }
 }
Пример #2
1
<?php

/* Change to the correct path if you copy this example! */
require __DIR__ . '/../../autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\CupsPrintConnector;
try {
    $connector = new CupsPrintConnector("EPSON_TM-T20");
    /* Print a "Hello world" receipt" */
    $printer = new Printer($connector);
    $printer->text("Hello World!\n");
    $printer->cut();
    /* Close printer */
    $printer->close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e->getMessage() . "\n";
}