Skip to content

Commit

Permalink
implement upside-down print command, closes #615
Browse files Browse the repository at this point in the history
  • Loading branch information
mike42 committed Oct 25, 2018
1 parent ed626c2 commit 8922bed
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 8922bed

Please sign in to comment.