{"id":13545538,"url":"https://github.com/mike42/escpos-php","last_synced_at":"2025-10-04T01:37:54.709Z","repository":{"id":13075585,"uuid":"15756427","full_name":"mike42/escpos-php","owner":"mike42","description":"PHP library for printing to ESC/POS-compatible thermal and impact printers","archived":false,"fork":false,"pushed_at":"2024-02-10T23:40:33.000Z","size":1723,"stargazers_count":2702,"open_issues_count":537,"forks_count":879,"subscribers_count":140,"default_branch":"development","last_synced_at":"2025-10-04T01:37:54.251Z","etag":null,"topics":["barcode","epson","escpos","hacktoberfest","php","printer","receipt-printer"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mike42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-09T04:14:38.000Z","updated_at":"2025-09-29T11:39:06.000Z","dependencies_parsed_at":"2022-07-07T18:40:29.538Z","dependency_job_id":"fec598a8-5b79-4a27-ae20-67b363244815","html_url":"https://github.com/mike42/escpos-php","commit_stats":{"total_commits":348,"total_committers":18,"mean_commits":"19.333333333333332","dds":0.09195402298850575,"last_synced_commit":"f414320fc510afcacd4cbb75902f827399dee429"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/mike42/escpos-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike42%2Fescpos-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike42%2Fescpos-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike42%2Fescpos-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike42%2Fescpos-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mike42","download_url":"https://codeload.github.com/mike42/escpos-php/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike42%2Fescpos-php/sbom","scorecard":{"id":645120,"data":{"date":"2025-08-11","repo":{"name":"github.com/mike42/escpos-php","commit":"f414320fc510afcacd4cbb75902f827399dee429"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/8 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T11:57:19.112Z","repository_id":13075585,"created_at":"2025-08-21T11:57:19.113Z","updated_at":"2025-08-21T11:57:19.113Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254469,"owners_count":25956598,"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","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["barcode","epson","escpos","hacktoberfest","php","printer","receipt-printer"],"created_at":"2024-08-01T11:01:05.157Z","updated_at":"2025-10-04T01:37:54.691Z","avatar_url":"https://github.com/mike42.png","language":"PHP","readme":"# ESC/POS Print Driver for PHP\n[![Build Status](https://travis-ci.org/mike42/escpos-php.svg?branch=master)](https://travis-ci.org/mike42/escpos-php) [![Latest Stable Version](https://poser.pugx.org/mike42/escpos-php/v/stable)](https://packagist.org/packages/mike42/escpos-php)\n[![Total Downloads](https://poser.pugx.org/mike42/escpos-php/downloads)](https://packagist.org/packages/mike42/escpos-php)\n[![License](https://poser.pugx.org/mike42/escpos-php/license)](https://packagist.org/packages/mike42/escpos-php)\n[![Coverage Status](https://coveralls.io/repos/github/mike42/escpos-php/badge.svg?branch=development)](https://coveralls.io/github/mike42/escpos-php?branch=development)\n\nThis project implements a subset of Epson's ESC/POS protocol for thermal receipt printers. It allows you to generate and print receipts with basic formatting, cutting, and barcodes on a compatible printer.\n\nThe library was developed to add drop-in support for receipt printing to any PHP app, including web-based point-of-sale (POS) applications.\n\n## Compatibility\n\n### Interfaces and operating systems\nThis driver is known to work with the following OS/interface combinations:\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003e\u0026nbsp;\u003c/th\u003e\n\u003cth\u003eLinux\u003c/th\u003e\n\u003cth\u003eMac\u003c/th\u003e\n\u003cth\u003eWindows\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003eEthernet\u003c/th\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003eUSB\u003c/th\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/linux-usb.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eNot tested\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/windows-usb.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003eUSB-serial\u003c/th\u003e\n\u003ctd\u003eYes\u003c/td\u003e\n\u003ctd\u003eYes\u003c/td\u003e\n\u003ctd\u003eYes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003eSerial\u003c/th\u003e\n\u003ctd\u003eYes\u003c/td\u003e\n\u003ctd\u003eYes\u003c/td\u003e\n\u003ctd\u003eYes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003eParallel\u003c/th\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/windows-lpt.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eNot tested\u003c/td\u003e\n\u003ctd\u003eYes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003eSMB shared\u003c/th\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eNo\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003cth\u003eCUPS hosted\u003c/th\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/cups.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://github.com/mike42/escpos-php/tree/master/example/interface/cups.php\"\u003eYes\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eNo\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### Printers\nMany thermal receipt printers support ESC/POS to some degree. This driver has been known to work with:\n\n- 3nStar RPT-008\n- Approx APPPOS80AM\n- AURES ODP-333\n- AURES ODP-500\n- Bematech-4200-TH\n- Bematech LR2000E\n- Birch PRP-085III\n- Bixolon SRP-350III\n- Bixolon SRP-350Plus\n- Black Copper BC-85AC\n- CHD TH-305N\n- Citizen CBM1000-II\n- Citizen CT-S310II\n- Dapper-Geyi Q583P \n- Daruma DR800\n- DR-MP200 (manufacturer unknown)\n- EPOS TEP 220M\n- Elgin i9\n- Epson EU-T332C\n- Epson FX-890 (requires `feedForm()` to release paper).\n- Epson TM-T20\n- Epson TM-T20II\n- Epson TM-T70\n- Epson TM-T70II\n- Epson TM-T81\n- Epson TM-T82II\n- Epson TM-T88II\n- Epson TM-T88III\n- Epson TM-T88IV\n- Epson TM-T88V\n- Epson TM-U220\n- Epson TM-U295 (requires `release()` to release slip).\n- Epson TM-U590 and TM-U590P\n- Equal (EQ-IT-001) POS-58\n- Everycom EC-58\n- Excelvan HOP-E200 \n- Excelvan HOP-E58\n- Excelvan HOP-E801\n- Gainscha GP-2120TF\n- Gainscha GP-5890x (Also marketed as EC Line 5890x)\n- Gainscha GP-U80300I (Also marketed as gprinter GP-U80300I)\n- gprinter GP-U80160I\n- HOIN HOP-H58\n- Ithaca iTherm 28\n- Hasar HTP 250\n- Metapace T-1\n- Metapace T-25\n- Nexa PX700\n- Nyear NP100\n- OKI RT322\n- OKI 80 Plus III\n- Orient BTP-R580\n- P-822D\n- P85A-401 (make unknown)\n- Partner Tech RP320\n- POSLIGNE ODP200H-III-G\n- QPOS Q58M\n- Rongta RP326US\n- Rongta RP58-U\n- Rongta RP80USE\n- SAM4S GIANT-100DB\n- Senor TP-100\n- Sewoo SLK-TS400\n- SEYPOS PRP-96\n- SEYPOS PRP-300 (Also marketed as TYSSO PRP-300)\n- SNBC BTP-R880NPIII\n- Solux SX-TP-88300\n- Sicar POS-80\n- Silicon SP-201 / RP80USE\n- SPRT SP-POS88V\n- Star BSC10\n- Star TSP100 ECO\n- Star TSP100III FuturePRNT\n- Star TSP-650\n- Star TUP-592\n- TVS RP45 Shoppe\n- Venus V248T\n- Xeumior SM-8330\n- Xprinter F-900\n- Xprinter XP-365B\n- Xprinter XP-58 Series\n- Xprinter XP-80C\n- Xprinter XP-90\n- XPrinter XP-Q20011\n- Xprinter XP-Q800\n- Zjiang NT-58H\n- Zjiang ZJ-5870\n- Zjiang ZJ-5890 (Also sold as POS-5890 by many vendors; ZJ-5890K, ZJ-5890T also work).\n- Zjiang ZJ-8220 (Also marketed as Excelvan ZJ-8220)\n- Zjiang ZJ-8250\n\nIf you use any other printer with this code, please [let us know](https://github.com/mike42/escpos-php/issues/new) so that it can be added to the list.\n\n## Basic usage\n\n### Include the library\n\n#### Composer\n\nThis library is designed for use with the `composer` PHP dependency manager. Simply add the `mike42/escpos-php` package to get started:\n\n```bash\ncomposer require mike42/escpos-php\n```\n\nIf you haven't used `composer` before, you can read about it at [getcomposer.org](https://getcomposer.org/).\n\n#### Requirements\n\nThis project has few hard dependencies:\n\n- PHP 7.3 or newer.\n- `json` extension, used to load bundled printer definitions (see [documentation](https://www.php.net/manual/en/book.json.php))\n- `intl` extension, used for character encoding (see [documentation](https://www.php.net/manual/en/book.intl.php))\n- `zlib` extension, used for de-compressing bundled resources (see [documentation](https://www.php.net/manual/en/book.zlib.php)).\n\nIt is also suggested that you install either `imagick` or `gd`, as these can be used to speed up image processing.\n\nA number of optional extensions can be added to enable more specific features. These\nare described in the \"suggest\" section of [composer.json](https://github.com/mike42/escpos-php/tree/master/composer.json).\n\n### The 'Hello World' receipt\n\nTo make use of this driver, your server (where PHP is installed) must be able to communicate with your printer. Start by generating a simple receipt and sending it to your printer using the command-line.\n\n```php\n\u003c?php\n/* Call this file 'hello-world.php' */\nrequire __DIR__ . '/vendor/autoload.php';\nuse Mike42\\Escpos\\PrintConnectors\\FilePrintConnector;\nuse Mike42\\Escpos\\Printer;\n$connector = new FilePrintConnector(\"php://stdout\");\n$printer = new Printer($connector);\n$printer -\u003e text(\"Hello World!\\n\");\n$printer -\u003e cut();\n$printer -\u003e close();\n```\n\nSome examples are below for common interfaces.\n\nCommunicate with a printer with an Ethernet interface using `netcat`:\n\n```bash\nphp hello-world.php | nc 10.x.x.x. 9100\n```\n\nA USB local printer connected with `usblp` on Linux has a device file (Includes USB-parallel interfaces):\n\n```bash\nphp hello-world.php \u003e /dev/usb/lp0\n```\n\nA computer installed into the local `cups` server is accessed through `lp` or `lpr`:\n\n```bash\nphp hello-world.php \u003e foo.txt\nlpr -o raw -H localhost -P printer foo.txt\n```\n\nA local or networked printer on a Windows computer is mapped in to a file, and generally requires you to share the printer first:\n\n```\nphp hello-world.php \u003e foo.txt\nnet use LPT1 \\\\server\\printer\ncopy foo.txt LPT1\ndel foo.txt\n```\n\nIf you have troubles at this point, then you should consult your OS and printer system documentation to try to find a working print command.\n\n### Using a PrintConnector\n\nTo print receipts from PHP, use the most applicable [PrintConnector](https://github.com/mike42/escpos-php/tree/master/src/Mike42/Escpos/PrintConnectors) for your setup. The connector simply provides the plumbing to get data to the printer.\n\nFor example, a `NetworkPrintConnector` accepts an IP address and port:\n\n```php\nuse Mike42\\Escpos\\PrintConnectors\\NetworkPrintConnector;\nuse Mike42\\Escpos\\Printer;\n$connector = new NetworkPrintConnector(\"10.x.x.x\", 9100);\n$printer = new Printer($connector);\ntry {\n    // ... Print stuff\n} finally {\n    $printer -\u003e close();\n}\n```\n\nWhile a serial printer might use:\n\n```php\nuse Mike42\\Escpos\\PrintConnectors\\FilePrintConnector;\nuse Mike42\\Escpos\\Printer;\n$connector = new FilePrintConnector(\"/dev/ttyS0\");\n$printer = new Printer($connector);\n```\n\nFor each OS/interface combination that's supported, there are examples in the compatibility section of how a `PrintConnector` would be constructed. If you can't get a `PrintConnector` to work, then be sure to include the working print command in your issue.\n\n### Using a CapabilityProfile\n\nSupport for commands and code pages varies between printer vendors and models. By default, the driver will accept UTF-8, and output commands that are suitable for Epson TM-series printers.\n\nWhen trying out a new brand of printer, it's a good idea to use the \"simple\" `CapabilityProfile`, which instructs the driver to avoid the use of advanced features (generally simpler image handling, ASCII-only text).\n\n```php\nuse Mike42\\Escpos\\PrintConnectors\\WindowsPrintConnector;\nuse Mike42\\Escpos\\CapabilityProfile;\n$profile = CapabilityProfile::load(\"simple\");\n$connector = new WindowsPrintConnector(\"smb://computer/printer\");\n$printer = new Printer($connector, $profile);\n```\n\nAs another example, Star-branded printers use different commands:\n\n```php\nuse Mike42\\Escpos\\PrintConnectors\\WindowsPrintConnector;\nuse Mike42\\Escpos\\CapabilityProfile;\n$profile = CapabilityProfile::load(\"SP2000\")\n$connector = new WindowsPrintConnector(\"smb://computer/printer\");\n$printer = new Printer($connector, $profile);\n```\n\nFor a list of available profiles, or to have support for your printer improved, please see the upstream [receipt-print-hq/escpos-printer-db](https://github.com/receipt-print-hq/escpos-printer-db) project.\n\n### Tips \u0026 examples\n\nOn Linux, your printer device file will be somewhere like `/dev/lp0` (parallel), `/dev/usb/lp1` (USB), `/dev/ttyUSB0` (USB-Serial), `/dev/ttyS0` (serial).\n\nOn Windows, the device files will be along the lines of `LPT1` (parallel) or `COM1` (serial). Use the `WindowsPrintConnector` to tap into system printing on Windows (eg. [Windows USB](https://github.com/mike42/escpos-php/tree/master/example/interface/windows-usb.php), [SMB](https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php) or [Windows LPT](https://github.com/mike42/escpos-php/tree/master/example/interface/windows-lpt.php)) - this submits print jobs via a queue rather than communicating directly with the printer.\n\nA complete real-world receipt can be found in the code of [Auth](https://github.com/mike42/Auth) in [ReceiptPrinter.php](https://github.com/mike42/Auth/blob/master/lib/misc/ReceiptPrinter.php). It includes justification, boldness, and a barcode.\n\nOther examples are located in the [example/](https://github.com/mike42/escpos-php/blob/master/example/) directory.\n\n## Available methods\n\n### __construct(PrintConnector $connector, CapabilityProfile $profile)\nConstruct new print object.\n\nParameters:\n- `PrintConnector $connector`: The PrintConnector to send data to.\n- `CapabilityProfile $profile` Supported features of this printer. If not set, the \"default\" CapabilityProfile will be used, which is suitable for Epson printers.\n\nSee [example/interface/](https://github.com/mike42/escpos-php/tree/master/example/interface/) for ways to open connections for different platforms and interfaces.\n\n### barcode($content, $type)\nPrint a barcode.\n\nParameters:\n\n- `string $content`: The information to encode.\n- `int $type`: The barcode standard to output. If not specified, `Printer::BARCODE_CODE39` will be used.\n\nCurrently supported barcode standards are (depending on your printer):\n\n- `BARCODE_UPCA`\n- `BARCODE_UPCE`\n- `BARCODE_JAN13`\n- `BARCODE_JAN8`\n- `BARCODE_CODE39`\n- `BARCODE_ITF`\n- `BARCODE_CODABAR`\n\nNote that some barcode standards can only encode numbers, so attempting to print non-numeric codes with them may result in strange behaviour.\n\n### bitImage(EscposImage $image, $size)\nSee [graphics()](#graphicsescposimage-image-size) below.\n\n### cut($mode, $lines)\nCut the paper.\n\nParameters:\n\n- `int $mode`: Cut mode, either `Printer::CUT_FULL` or `Printer::CUT_PARTIAL`. If not specified, `Printer::CUT_FULL` will be used.\n- `int $lines`: Number of lines to feed before cutting. If not specified, 3 will be used.\n\n### feed($lines)\nPrint and feed line / Print and feed n lines.\n\nParameters:\n\n- `int $lines`: Number of lines to feed\n\n### feedForm()\nSome printers require a form feed to release the paper. On most printers, this command is only useful in page mode, which is not implemented in this driver.\n\n### feedReverse($lines)\nPrint and reverse feed n lines.\n\nParameters:\n\n- `int $lines`: number of lines to feed. If not specified, 1 line will be fed.\n\n### graphics(EscposImage $image, $size)\nPrint an image to the printer.\n\nParameters:\n\n- `EscposImage $img`: The image to print.\n- `int $size`: Output size modifier for the image.\n\nSize modifiers are:\n\n- `IMG_DEFAULT` (leave image at original size)\n- `IMG_DOUBLE_WIDTH`\n- `IMG_DOUBLE_HEIGHT`\n\nA minimal example:\n\n```php\n\u003c?php\n$img = EscposImage::load(\"logo.png\");\n$printer -\u003e graphics($img);\n```\n\nSee the [example/](https://github.com/mike42/escpos-php/blob/master/example/) folder for detailed examples.\n\nThe function [bitImage()](#bitimageescposimage-image-size) takes the same parameters, and can be used if your printer doesn't support the newer graphics commands. As an additional fallback, the `bitImageColumnFormat()` function is also provided.\n\n### initialize()\nInitialize printer. This resets formatting back to the defaults.\n\n### pdf417Code($content, $width, $heightMultiplier, $dataColumnCount, $ec, $options)\nPrint a two-dimensional data code using the PDF417 standard.\n\nParameters:\n\n- `string $content`: Text or numbers to store in the code\n- `number $width`: Width of a module (pixel) in the printed code. Default is 3 dots.\n- `number $heightMultiplier`: Multiplier for height of a module. Default is 3 times the width.\n- `number $dataColumnCount`: Number of data columns to use. 0 (default) is to auto-calculate. Smaller numbers will result in a narrower code, making larger pixel sizes possible. Larger numbers require smaller pixel sizes.\n- `real $ec`: Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).\n- `number $options`: Standard code `Printer::PDF417_STANDARD` with start/end bars, or truncated code `Printer::PDF417_TRUNCATED` with start bars only.\n\n### pulse($pin, $on_ms, $off_ms)\nGenerate a pulse, for opening a cash drawer if one is connected. The default settings (0, 120, 240) should open an Epson drawer.\n\nParameters:\n\n- `int $pin`: 0 or 1, for pin 2 or pin 5 kick-out connector respectively.\n- `int $on_ms`: pulse ON time, in milliseconds.\n- `int $off_ms`: pulse OFF time, in milliseconds.\n\n### qrCode($content, $ec, $size, $model)\nPrint the given data as a QR code on the printer.\n\n- `string $content`: The content of the code. Numeric data will be more efficiently compacted.\n- `int $ec` Error-correction level to use. One of `Printer::QR_ECLEVEL_L` (default), `Printer::QR_ECLEVEL_M`, `Printer::QR_ECLEVEL_Q` or `Printer::QR_ECLEVEL_H`. Higher error correction results in a less compact code.\n- `int $size`: Pixel size to use. Must be 1-16 (default 3)\n- `int $model`: QR code model to use. Must be one of `Printer::QR_MODEL_1`, `Printer::QR_MODEL_2` (default) or `Printer::QR_MICRO` (not supported by all printers).\n\n### selectPrintMode($mode)\nSelect print mode(s).\n\nParameters:\n\n- `int $mode`: The mode to use. Default is `Printer::MODE_FONT_A`, with no special formatting. This has a similar effect to running `initialize()`.\n\nSeveral MODE_* constants can be OR'd together passed to this function's `$mode` argument. The valid modes are:\n\n- `MODE_FONT_A`\n- `MODE_FONT_B`\n- `MODE_EMPHASIZED`\n- `MODE_DOUBLE_HEIGHT`\n- `MODE_DOUBLE_WIDTH`\n- `MODE_UNDERLINE`\n\n### setBarcodeHeight($height)\nSet barcode height.\n\nParameters:\n\n- `int $height`: Height in dots. If not specified, 8 will be used.\n\n### setBarcodeWidth($width)\nSet barcode bar width.\n\nParameters:\n\n- `int $width`: Bar width in dots. If not specified, 3 will be used. Values above 6 appear to have no effect.\n\n### setColor($color)\nSelect print color - on printers that support multiple colors.\n\nParameters:\n\n- `int $color`: Color to use. Must be either `Printer::COLOR_1` (default), or `Printer::COLOR_2`\n\n### setDoubleStrike($on)\nTurn double-strike mode on/off.\n\nParameters:\n\n- `boolean $on`: true for double strike, false for no double strike.\n\n### setEmphasis($on)\nTurn emphasized mode on/off.\n\nParameters:\n\n- `boolean $on`: true for emphasis, false for no emphasis.\n\n### setFont($font)\nSelect font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).\n\nParameters:\n\n- `int $font`: The font to use. Must be either `Printer::FONT_A`, `Printer::FONT_B`, or `Printer::FONT_C`.\n\n### setJustification($justification)\nSelect justification.\n\nParameters:\n\n- `int $justification`: One of `Printer::JUSTIFY_LEFT`, `Printer::JUSTIFY_CENTER`, or `Printer::JUSTIFY_RIGHT`.\n\n### setLineSpacing($height)\n\nSet the height of the line.\n\nSome printers will allow you to overlap lines with a smaller line feed.\n\nParameters:\n\n- `int\t$height`:\tThe height of each line, in dots. If not set, the printer will reset to its default line spacing.\n\n### setPrintLeftMargin($margin)\n\nSet print area left margin. Reset to default with `Printer::initialize()`.\n\nParameters:\n\n- `int $margin`: The left margin to set on to the print area, in dots.\n\n### setPrintWidth($width)\n\nSet print area width. This can be used to add a right margin to the print area. Reset to default with `Printer::initialize()`.\n\nParameters:\n\n- `int $width`: The width of the page print area, in dots.\n\n### setReverseColors($on)\nSet black/white reverse mode on or off. In this mode, text is printed white on a black background.\n\nParameters:\n\n- `boolean $on`: True to enable, false to disable.\n\n### setTextSize($widthMultiplier, $heightMultiplier)\nSet the size of text, as a multiple of the normal size.\n\nParameters:\n\n- `int $widthMultiplier`: Multiple of the regular height to use (range 1 - 8).\n- `int $heightMultiplier`: Multiple of the regular height to use (range 1 - 8).\n\n### setUnderline($underline)\nSet underline for printed text.\n\nParameters:\n\n- `int $underline`: Either `true`/`false`, or one of `Printer::UNDERLINE_NONE`, `Printer::UNDERLINE_SINGLE` or `Printer::UNDERLINE_DOUBLE`. Defaults to `Printer::UNDERLINE_SINGLE`.\n\n### text($str)\nAdd text to the buffer. Text should either be followed by a line-break, or `feed()` should be called after this.\n\nParameters:\n\n- `string $str`: The string to print.\n\n# Further notes\nPosts I've written up for people who are learning how to use receipt printers:\n\n* [What is ESC/POS, and how do I use it?](https://mike42.me/blog/what-is-escpos-and-how-do-i-use-it), which documents the output of `example/demo.php`.\n* [Setting up an Epson receipt printer](https://mike42.me/blog/2014-20-26-setting-up-an-epson-receipt-printer)\n* [Getting a USB receipt printer working on Linux](https://mike42.me/blog/2015-03-getting-a-usb-receipt-printer-working-on-linux)\n\n# Development\n\nThis code is MIT licensed, and you are encouraged to contribute any modifications back to the project.\n\nFor development, it's suggested that you load `imagick`, `gd` and `Xdebug` PHP extensions.\n\nThe tests are executed on [Travis CI](https://travis-ci.org/mike42/escpos-php) over PHP 7.3, 7.4 and 8.0. Older versions of PHP are not supported in the current release, nor is HHVM.\n\nFetch a copy of this code and load dependencies with composer:\n\n    git clone https://github.com/mike42/escpos-php\n    cd escpos-php/\n    composer install\n\nExecute unit tests via `phpunit`:\n\n    php vendor/bin/phpunit --coverage-text\n\nThis project uses the PSR-2 standard, which can be checked via [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer):\n\n    php vendor/bin/phpcs --standard=psr2 src/ -n\n\nThe developer docs are build with [doxygen](https://github.com/doxygen/doxygen). Re-build them to check for documentation warnings:\n\n    make -C doc clean \u0026\u0026 make -C doc\n\nPull requests and bug reports welcome.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike42%2Fescpos-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmike42%2Fescpos-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike42%2Fescpos-php/lists"}