ubl / png-print-zplii
将PNG图片转换为打印用的ZPL内部图形格式。
0.2.0
2022-10-19 11:24 UTC
Requires
- php: >=8.0
- ext-gd: *
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: dev-main
- squizlabs/php_codesniffer: ^3.5
This package is not auto-updated.
Last update: 2024-09-18 21:01:18 UTC
README
使用Zebra ZPL II打印机语言打印PNG图像的辅助类。
类返回ZPLII命令 ~DG 用于将图像下载到打印机,以及 ^XG 用于打印未压缩的PNG图像。
此外,还有一些方法可以在打印前操作图像,以及打印机上的设置,如打印的起始位置、图像的旋转和打印机上的内存位置。
关于此问题的任何反思和一小部分研究成果,您可以在这里找到。
需求
- PHP 7.3+
安装
要在您的应用中安装包或进行测试,请使用composer
composer require ubl/png-print-zplii
# Otherwise add class to your composer dependencies
{
"require": {
"ubl/png-print-zplii": "master"
}
}
使用方法
use PrintZplii\PrintZplii;
$print = new PrintZplii();
// setSource - Set file path to image. (Obligatory)
$print->setSource('Filepath to image');
// setRotation - Set degree to rotate image for print (Optional, Default: 0, Range: 0-360)
$print->setRotation(0);
// setPositionX - Set position on x graph for start printing. (Optional, Default: 0, Range > 0)
$print->setPositionX(0);
// setPositionY - Set position on y graph for start printing. (Optional, Default: 0, Range > 0)
$print->setPositionY(0);
// setTarget - Set filename for uploading image. (Optional, Default: UNKNOWN.GRF, Regex [A-Z0-9]{1,8}\\.GRF)
$print->setTarget('UNKNOWN.GRF');
// setMemoryType - Set memory type where image should be stored at printer (Optional,
// Default: R (for FLASH/DRAM), Options: R,E,B,A)
$print->setMemoryType('R');
// Public processing methods:
// getZplDG - Return only ~DG command for downloading image to printer
$print->getZplDG();
// getPrintCommandZplII - Return complete command of downloading image to printer
// and then processing print with ^XG command.
$print->getPrintCommand();
开发
在生产阶段,类没有任何依赖的包。在开发阶段,使用 `
composer install`
安装必要的开发包,例如:PHPUnit 和 PHP Codesniffer。
// For code sniffer test on coding standard PSR12 run:
composer csphp
// For PHPUnit tests run:
composer phpunit
// To run both tests in one
composer test
链接
灵感来源
- 用于ZPL图像的JavaScript库
- https://github.com/robgridley/zebra
- https://github.com/SimonWaldherr/zplgfa
- https://github.com/zgldh/crc16-php
- https://github.com/kittinan/php-crc