ubl / png-print-zplii
Converts PNGs to ZPL internal graphic format for printing.
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-12-11 22:06:28 UTC
README
Helper class for printing PNG images using Zebra ZPL II printer language.
Class returns ZPLII commands ~DG for downloading image to printer and ^XG for printing uncompressed PNG image.
In addition there are a few methods to manipulate image before printing and settings on printer like start position of print, rotation of image and memory location on printer.
Any reflections and a small tableau of research on this issue you will find here.
Requirements
- PHP 7.3+
Installation
To install package in your app or for testing use composer:
composer require ubl/png-print-zplii
# Otherwise add class to your composer dependencies
{
"require": {
"ubl/png-print-zplii": "master"
}
}
Usage
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();
Development
Class comes without any dependency package at productive stage. For development use `
composer install`
to install necessary dev packages as for example: PHPUnit and 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
Links
Inspired by
- JavaScript library for ZPL images
- https://github.com/robgridley/zebra
- https://github.com/SimonWaldherr/zplgfa
- https://github.com/zgldh/crc16-php
- https://github.com/kittinan/php-crc