mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.58k stars 863 forks source link

Code128 prints prefix #762

Open mattoldred opened 5 years ago

mattoldred commented 5 years ago

This might only be an issue with my very cheap Excelvan printer but when I print CODE128 barcodes it prints the {B prefix as well as the content. $content = "MYCONTENT"; $printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW); $printer -> barcode("{B".$content, Printer::BARCODE_CODE128);

Results in: barcode

If I change the CODE128 regex in Printer.php to "/^[\x00-\x7F]+$/" then it seems to work and I can use:

$content = "MYCONTENT"; $printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW); $printer -> barcode($content, Printer::BARCODE_CODE128);

to get: barcode2

mike42 commented 5 years ago

I scanned these two bar-codes, and can basically confirm that this does not match the behaviour of Epson printers.

Can you please share your exact model of printer? We may be able to add a flag to change how we print.

I've marked this as an enhancement, because the API would be clearer if we made {A/{B/{C optional anyway. It weakens the abstraction, since you really need an ESC/POS manual to know how to specify CODE128 barcodes correctly at the moment.

mattoldred commented 5 years ago

I think it is an "Excelvan E801 USB". It must not be very compliant as I have never been able to get QRCodes working despite it claiming to support them (the test page has one).

I think it is actually a rebadged HOIN HOP-E801 as there is "CopyRight@2015-2016 Hoin All Rights Reserved." on the webserver page. http://hoinprinter.com/en/products/show/80mm-Thermal-Receipt-Printer-2