1234567891011121314151617181920212223242526272829
  1. <?php
  2. /*
  3. * Example showing how to return binary data back to the user.
  4. *
  5. * This is intended for the "Star TSP650IIcloudPRNT" printer.
  6. */
  7. require __DIR__ . '/../../vendor/autoload.php';
  8. use Mike42\Escpos\Printer;
  9. use Mike42\Escpos\PrintConnectors\DummyPrintConnector;
  10. use Mike42\Escpos\CapabilityProfile;
  11. // Make sure you load a Star print connector or you may get gibberish.
  12. $connector = new DummyPrintConnector();
  13. $profile = CapabilityProfile::load("TSP600");
  14. $printer = new Printer($connector);
  15. $printer -> text("Hello world!\n");
  16. $printer -> cut();
  17. // Get the data out as a string
  18. $data = $connector -> getData();
  19. // Return it, check the manual for specifics.
  20. header('Content-type: application/octet-stream');
  21. header('Content-Length: '.strlen($data));
  22. echo $data;
  23. // Close the printer when done.
  24. $printer -> close();