ramytalal / label-printer
An implementation of the Brother label printer API.
Installs: 32 574
Dependents: 0
Suggesters: 0
Security: 0
Stars: 65
Watchers: 9
Forks: 22
Open Issues: 13
Requires
- php: >=5.5.9
Requires (Dev)
- phpunit/phpunit: ~4.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-10-30 01:53:43 UTC
README
This library is a WIP.
Easily print labels with a Brother label printer.
This library is tested with the following Brother printers,
- QL-580N - tested by xelan
- QL-720NW - tested by RamyTalal
- QL-810W - tested by ntaylor-86
- QL-820NWB - Tested by ArienClaij and Luc99
- QL-1110NWB - Tested by JETomi
so it may not work with other printers.
Install
Composer
$ composer require RamyTalal/Label-Printer
Usage
ESC/P
use Talal\LabelPrinter\Printer; use Talal\LabelPrinter\Mode\Escp; use Talal\LabelPrinter\Command; $stream = stream_socket_client('tcp://192.168.1.8:9100', $errorNumber, $errorString); $printer = new Printer(new Escp($stream)); $font = new Command\Font('brussels', Command\Font::TYPE_OUTLINE); $printer->addCommand(new Command\CharStyle(Command\CharStyle::NORMAL)); $printer->addCommand($font); $printer->addCommand(new Command\CharSize(46, $font)); $printer->addCommand(new Command\Align(Command\Align::CENTER)); $printer->addCommand(new Command\Text('Hallo')); $printer->addCommand(new Command\Cut(Command\Cut::FULL)); $printer->printLabel(); fclose($stream);
AutoCut Feature
// Disable the AutoCut on the printer $printer->addCommand(new Command\AutoCut(Command\AutoCut::DISABLED)); // Enable the AutoCut on the printer $printer->addCommand(new Command\AutoCut(Command\AutoCut::ENABLED));
Template
use Talal\LabelPrinter\Printer; use Talal\LabelPrinter\Mode\Template; use Talal\LabelPrinter\Command; $stream = stream_socket_client('tcp://192.168.1.8:9100', $errorNumber, $errorString); $printer = new Printer(new Template(2, $stream)); $printer->addCommand(new Command\ObjectCommand('title', 'R. Talal')); $printer->addCommand(new Command\ObjectCommand('address', 'H.H. Schefferlaan 9')); $printer->addCommand(new Command\ObjectCommand('postalcode', '7771 CW')); $printer->addCommand(new Command\ObjectCommand('city', 'Hardenberg')); $printer->printLabel(); fclose($stream);
Barcode generation
use Talal\LabelPrinter\Printer; use Talal\LabelPrinter\Mode\Template; use Talal\LabelPrinter\Command; $stream = stream_socket_client('tcp://192.168.1.8:9100', $errorNumber, $errorString); $printer = new Printer(new Template(2, $stream)); $printer->addCommand(new Command\Barcode('1234', 80, Command\Barcode::WIDTH_SMALL, 'code39', false, 2.5)); // or QR code // $printer->addCommand(new Command\QrCode('https://example.com')); $printer->printLabel(); fclose($stream);
Testing
$ composer test
TODO
- Documentation
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
The MIT License (MIT). Please see License File for more information.