graphics.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /* Print-outs using the newer graphics print command */
  3. require __DIR__ . '/../vendor/autoload.php';
  4. use Mike42\Escpos\Printer;
  5. use Mike42\Escpos\EscposImage;
  6. use Mike42\Escpos\PrintConnectors\FilePrintConnector;
  7. $connector = new FilePrintConnector("php://stdout");
  8. $printer = new Printer($connector);
  9. try {
  10. $tux = EscposImage::load("resources/tux.png", false);
  11. $printer -> graphics($tux);
  12. $printer -> text("Regular Tux.\n");
  13. $printer -> feed();
  14. $printer -> graphics($tux, Printer::IMG_DOUBLE_WIDTH);
  15. $printer -> text("Wide Tux.\n");
  16. $printer -> feed();
  17. $printer -> graphics($tux, Printer::IMG_DOUBLE_HEIGHT);
  18. $printer -> text("Tall Tux.\n");
  19. $printer -> feed();
  20. $printer -> graphics($tux, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT);
  21. $printer -> text("Large Tux in correct proportion.\n");
  22. $printer -> cut();
  23. } catch (Exception $e) {
  24. /* Images not supported on your PHP, or image file not found */
  25. $printer -> text($e -> getMessage() . "\n");
  26. }
  27. $printer -> close();