Skip to content

Commit

Permalink
Merge pull request #652 from mike42/615-upside-down
Browse files Browse the repository at this point in the history
Implement upside-down print command
  • Loading branch information
mike42 committed Oct 25, 2018
2 parents ec9c539 + 8922bed commit 7f7c02b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Mike42/Escpos/Printer.php
Expand Up @@ -972,7 +972,18 @@ public function setUnderline($underline = Printer::UNDERLINE_SINGLE)
self::validateInteger($underline, 0, 2, __FUNCTION__);
$this -> connector -> write(self::ESC . "-" . chr($underline));
}


/**
* Print each line upside-down (180 degrees rotated).
*
* @param boolean $on True to enable, false to disable.
*/
public function setUpsideDown($on = true)
{
self::validateBoolean($on, __FUNCTION__);
$this -> connector -> write(self::ESC . "{" . ($on ? chr(1) : chr(0)));
}

/**
* Add text to the buffer.
*
Expand Down
7 changes: 7 additions & 0 deletions test/unit/EscposTest.php
Expand Up @@ -1100,6 +1100,13 @@ public function testPrintLeftMarginInvalid()
$this -> printer -> setPrintLeftMargin(70000);
$this -> checkOutput();
}

/* Upside-down print */
public function testSetUpsideDown()
{
$this -> printer -> setUpsideDown(true);
$this -> checkOutput("\x1b@\x1b{\x01");
}
}

/*
Expand Down

0 comments on commit 7f7c02b

Please sign in to comment.