ramytalal / label-printer
Brother 标签打印机 API 的实现。
1.2.0
2023-09-23 14:04 UTC
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-08-30 01:28:50 UTC
README
这个库是一个正在进行中的工作。
轻松使用 Brother 标签打印机打印标签。
此库与以下 Brother 打印机进行了测试,
- QL-580N - 由 xelan 测试
- QL-720NW - 由 RamyTalal 测试
- QL-810W - 由 ntaylor-86 测试
- QL-820NWB - 由 ArienClaij 和 Luc99 测试
- QL-1110NWB - 由 JETomi 测试
因此,它可能与其他打印机不兼容。
安装
Composer
$ composer require RamyTalal/Label-Printer
用法
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);
自动裁剪功能
// 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));
模板
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);
条码生成
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);
测试
$ composer test
待办事项
- 文档
贡献
请参阅 CONTRIBUTING 和 CONDUCT 了解详细信息。
致谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。