{"id":25016400,"url":"https://github.com/php-aidc/label-printer","last_synced_at":"2025-04-13T00:35:40.638Z","repository":{"id":45649461,"uuid":"276090006","full_name":"php-aidc/label-printer","owner":"php-aidc","description":"A PHP package for label printers (Honeywell, Intermec, TSC)","archived":false,"fork":false,"pushed_at":"2021-12-28T11:03:20.000Z","size":100,"stargazers_count":58,"open_issues_count":3,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T00:35:27.970Z","etag":null,"topics":["aidc","fingerprint","honeywell","intermec","php7","printer","tsc","tspl","tspl2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-aidc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-30T12:18:29.000Z","updated_at":"2025-02-19T09:21:54.000Z","dependencies_parsed_at":"2022-08-24T00:50:46.623Z","dependency_job_id":null,"html_url":"https://github.com/php-aidc/label-printer","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-aidc%2Flabel-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-aidc%2Flabel-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-aidc%2Flabel-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-aidc%2Flabel-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-aidc","download_url":"https://codeload.github.com/php-aidc/label-printer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650449,"owners_count":21139671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aidc","fingerprint","honeywell","intermec","php7","printer","tsc","tspl","tspl2"],"created_at":"2025-02-05T09:29:25.447Z","updated_at":"2025-04-13T00:35:40.617Z","avatar_url":"https://github.com/php-aidc.png","language":"PHP","readme":"\u003ch1 align=\"center\"\u003ePhpAidc LabelPrinter\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/php-aidc/label-printer\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/php-aidc/label-printer.svg?style=flat\" alt=\"Latest Version on Packagist\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/php-aidc/label-printer/actions?workflow=tests\"\u003e\u003cimg src=\"https://github.com/php-aidc/label-printer/workflows/tests/badge.svg\" alt=\"Testing\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/php-aidc/label-printer\"\u003e\u003cimg src=\"https://img.shields.io/scrutinizer/g/php-aidc/label-printer.svg?style=flat\" alt=\"Quality Score\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/php-aidc/label-printer/?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/scrutinizer/coverage/g/php-aidc/label-printer/master.svg?style=flat\" alt=\"Code Coverage\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/php-aidc/label-printer\"\u003e\u003cimg src=\"https://poser.pugx.org/php-aidc/label-printer/downloads?format=flat\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://raw.githubusercontent.com/php-aidc/label-printer/master/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-428F7E\" alt=\"License MIT\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nPhpAidc LabelPrinter is a library that help you create and print labels on printers that support\nDirect Protocol, Fingerprint, TSPL/TSPL2 languages (Honeywell, Intermec, TSC) via TCP/IP.\n\n---\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Basic usage](#basic-usage)\n\n## Requirements\n- PHP 7.1+\n- ext-mbstring\n\n## Installation\n\nLabelPrinter is installed via [Composer](https://getcomposer.org/):\n```bash\ncomposer require php-aidc/label-printer\n```\n\nYou can of course also manually edit your composer.json file\n```json\n{\n    \"require\": {\n       \"php-aidc/label-printer\": \"v0.4\"\n    }\n}\n```\n\n## Basic usage\n\n\u003e Some TSPL2-like printers, such as Atol BP41/Rongta RP410, do not support all TSPL2 features.\n\n#### Read data from printer\n\n```php\nuse PhpAidc\\LabelPrinter\\Printer;\nuse PhpAidc\\LabelPrinter\\Connector\\NetworkConnector;\n\n$printer = new Printer(new NetworkConnector('192.168.x.x'));\n\n\\var_dump($printer-\u003eask('? VERSION$(0)'));\n\n// \"Direct Protocol  10.15.017559   \\r\\n\"\n```\n\n#### Create and print label\n```php\nuse PhpAidc\\LabelPrinter\\Enum\\Unit;\nuse PhpAidc\\LabelPrinter\\Enum\\Anchor;\nuse PhpAidc\\LabelPrinter\\Enum\\Charset;\nuse PhpAidc\\LabelPrinter\\Printer;\nuse PhpAidc\\LabelPrinter\\Label\\Label;\nuse PhpAidc\\LabelPrinter\\Label\\Element;\nuse PhpAidc\\LabelPrinter\\CompilerFactory;\nuse PhpAidc\\LabelPrinter\\Connector\\NetworkConnector;\n\n$label = Label::create(Unit::MM(), 43, 25)\n    -\u003echarset(Charset::UTF8())\n    -\u003eadd(Element::textBlock(168, 95, 'Hello!', 'Univers', 8)-\u003ebox(338, 100, 0)-\u003eanchor(Anchor::CENTER()))\n    -\u003eadd(Element::barcode(10, 10, '123456', 'CODE93')-\u003eheight(60))\n;\n\n(new Printer(new NetworkConnector('192.168.x.x'), CompilerFactory::tspl()))-\u003eprint($label);\n```\n\n#### Add elements only for a specific language\n```php\nuse PhpAidc\\LabelPrinter\\Label\\Label;\nuse PhpAidc\\LabelPrinter\\Label\\Element;\nuse PhpAidc\\LabelPrinter\\Language\\Tspl;\nuse PhpAidc\\LabelPrinter\\Language\\Fingerprint;\n\n$label = Label::create()\n    -\u003efor(Fingerprint::class, static function (Label $label) {\n        $label-\u003eadd(Element::textLine(168, 95, 'Hello!', 'Univers', 8));\n    })\n    -\u003efor(Tspl::class, static function (Label $label) {\n        $label-\u003eadd(Element::textLine(10, 10, 'Hello!', 'ROMAN.TTF', 8));\n    })\n;\n```\n\n#### Add elements if some value is truthy\n```php\nuse PhpAidc\\LabelPrinter\\Label\\Label;\nuse PhpAidc\\LabelPrinter\\Label\\Element;\n\n$text = '';\n\n$label = Label::create()\n    -\u003ewhen($text, static function (Label $label, $text) {\n        // will not be added until the $text is empty\n        $label-\u003eadd(Element::textLine(168, 95, $text, 'Univers', 8));\n    })\n;\n```\n\n#### Print images\n```php\nuse PhpAidc\\LabelPrinter\\Label\\Label;\nuse PhpAidc\\LabelPrinter\\Label\\Element;\nuse PhpAidc\\LabelPrinter\\Language\\Tspl;\nuse PhpAidc\\LabelPrinter\\Language\\Fingerprint;\n\n$image = new \\Imagick('gift.svg');\n\n$label = Label::create()\n    -\u003efor(Fingerprint::class, static function (Label $label) {\n        // from printer's memory — png, bmp, pcx\n        $label-\u003eadd(Element::intImage(10, 10, 'GLOBE.1'));\n        // from filesystem\n        $label-\u003eadd(Element::extImage(10, 10, \\realpath('alien.png')));\n    })\n    -\u003efor(Tspl::class, static function (Label $label) {\n        // from printer's memory — bmp, pcx\n        $label-\u003eadd(Element::intImage(10, 10, 'ALIEN.BMP'));\n    })\n    // from filesystem via Imagick — any supported types\n    -\u003eadd(Element::bitmap(50, 10, $image))\n;\n```\n\n#### Print text with emulation\n```php\nuse PhpAidc\\LabelPrinter\\Label\\Label;\nuse PhpAidc\\LabelPrinter\\Label\\Element;\n\n$label = Label::create()\n    -\u003eadd(Element::textLine(10, 10, 'Hello!', '/path/to/font/roboto.ttf', 20)-\u003eemulate())\n    -\u003eadd(Element::textBlock(100, 10, 'Hello again!', '/path/to/font/roboto.ttf', 20)-\u003ebox(300, 20)-\u003eemulate())\n;\n```\nText will be drawn with Imagick and printed as bitmap.\n\n#### Specify the number of copies\n```php\nuse PhpAidc\\LabelPrinter\\Label\\Label;\nuse PhpAidc\\LabelPrinter\\Label\\Element;\n\n$label = Label::create()\n    -\u003eadd(Element::textLine(168, 95, 'Hello!', 'Univers', 8))\n    -\u003ecopies(3)\n;\n```\n\n#### Batch printing\n```php\nuse PhpAidc\\LabelPrinter\\Printer;\nuse PhpAidc\\LabelPrinter\\Label\\Batch;\nuse PhpAidc\\LabelPrinter\\Label\\Label;\nuse PhpAidc\\LabelPrinter\\Label\\Element;\nuse PhpAidc\\LabelPrinter\\CompilerFactory;\nuse PhpAidc\\LabelPrinter\\Connector\\NetworkConnector;\n\n$batch = (new Batch())\n    -\u003eadd(Label::create()-\u003eadd(Element::textLine(168, 95, 'Hello!', 'Univers', 8)))\n    -\u003eadd(Label::create()-\u003eadd(Element::textLine(168, 95, 'Bye!', 'Univers', 8)))\n;\n\n(new Printer(new NetworkConnector('192.168.x.x'), CompilerFactory::fingerprint()))-\u003eprint($label);\n```\n\n## License\n\nThe PhpAidc LabelPrinter is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).\n\n\u003e Some ideas taken from [mike42/escpos-php](https://github.com/mike42/escpos-php).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-aidc%2Flabel-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-aidc%2Flabel-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-aidc%2Flabel-printer/lists"}