Skip to content

Commit

Permalink
fix(barcode): fix epson barcode height and width
Browse files Browse the repository at this point in the history
  • Loading branch information
Francimar Alves committed Aug 21, 2023
1 parent 9ad19c3 commit b1ad506
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 11 deletions.
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Thermal/Profile/Daruma.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function barcode($data, $format)
Printer::BARCODE_CODE128 => 5,
];
$new_format = $tipo[$format];
$this->getConnection()->write("\eb" . chr($new_format) . chr(2) . chr(50) . chr(0) . $data . chr(0));
$this->getConnection()->write("\eb" . chr($new_format) . chr(2) . chr(90) . chr(0) . $data . chr(0));
}

public function qrcode($data, $size)
Expand Down
4 changes: 2 additions & 2 deletions src/Thermal/Profile/Diebold.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function barcode($data, $format)
$new_format = $tipo[$format];
if ($format === Printer::BARCODE_CODE128) {
$len = strlen($data);
$this->getConnection()->write("\e|" . $new_format . chr(50) . chr(0b00010010) . chr(0) . chr($len) . $data);
$this->getConnection()->write("\e|" . $new_format . chr(90) . chr(0b00010010) . chr(0) . chr($len) . $data);
} else {
$this->getConnection()->write("\e|" . $new_format . chr(50) . chr(0b00010010) . chr(0) . $data);
$this->getConnection()->write("\e|" . $new_format . chr(90) . chr(0b00010010) . chr(0) . $data);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/Thermal/Profile/Epson.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ public function drawer($number, $on_time, $off_time)

public function barcode($data, $format)
{
$width = 2;
$height = 90;
$showDigits = 0; // 0 => false, 2 => true
$this->getConnection()->write("\x1dw" . chr($width));
$this->getConnection()->write("\x1dh" . chr($height));
$this->getConnection()->write("\x1dH" . chr($showDigits));
if ($format === Printer::BARCODE_CODE128) {
$len = strlen($data);
$this->getConnection()->write("\x1dk" . chr($format) . chr($len) . $data);
Expand Down
Binary file modified tests/resources/barcode_IM453_Diebold.bin
Binary file not shown.
Binary file modified tests/resources/barcode_MP-4200_TH.bin
Binary file not shown.
Binary file modified tests/resources/barcode_code128_IM453_Diebold.bin
Binary file not shown.
Binary file modified tests/resources/barcode_code128_MP-4200_TH.bin
Binary file not shown.
Binary file modified tests/resources/barcode_code128_daruma.bin
Binary file not shown.
Binary file modified tests/resources/barcode_daruma.bin
Binary file not shown.

0 comments on commit b1ad506

Please sign in to comment.