{"id":13468778,"url":"https://github.com/Klemen1337/node-thermal-printer","last_synced_at":"2025-03-26T05:31:18.691Z","repository":{"id":32088853,"uuid":"35660914","full_name":"Klemen1337/node-thermal-printer","owner":"Klemen1337","description":"Node.js module for Epson, Star, Tanca, Drauma and Brother thermal printers command line printing.","archived":false,"fork":false,"pushed_at":"2024-08-27T08:34:05.000Z","size":294,"stargazers_count":773,"open_issues_count":22,"forks_count":244,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-10-29T15:47:00.552Z","etag":null,"topics":["brother","drauma","epson","nodejs","npm","npm-package","printer","star","thermal-printer","thermal-printing","tranca"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Klemen1337.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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":"2015-05-15T07:46:47.000Z","updated_at":"2024-10-23T11:03:28.000Z","dependencies_parsed_at":"2023-02-17T16:45:56.536Z","dependency_job_id":"f68d5257-7d80-422d-8e45-fe80a16400e9","html_url":"https://github.com/Klemen1337/node-thermal-printer","commit_stats":{"total_commits":128,"total_committers":27,"mean_commits":"4.7407407407407405","dds":0.6640625,"last_synced_commit":"488e2a8a8af5964d7e3cbe4652a0ad6d0f98e9cb"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Klemen1337%2Fnode-thermal-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Klemen1337%2Fnode-thermal-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Klemen1337%2Fnode-thermal-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Klemen1337%2Fnode-thermal-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Klemen1337","download_url":"https://codeload.github.com/Klemen1337/node-thermal-printer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245047979,"owners_count":20552430,"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":["brother","drauma","epson","nodejs","npm","npm-package","printer","star","thermal-printer","thermal-printing","tranca"],"created_at":"2024-07-31T15:01:18.908Z","updated_at":"2025-03-26T05:31:18.678Z","avatar_url":"https://github.com/Klemen1337.png","language":"JavaScript","readme":"# Node Thermal Printer v4.4.5\n\nNode.js module for Epson, Star, Tanca, Daruma, and Brother thermal printers command line printing.\n\n[![Join the chat at https://gitter.im/Klemen1337/node-thermal-printer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Klemen1337/node-thermal-printer?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## Installation\n\n```bash\nnpm install node-thermal-printer\n```\n\n### Linux specific\n\nLinux requires build-essentials\n\n```bash\nsudo apt-get install build-essential\n```\n\n### Browser specifics\n\nWhen using inside a browser, the network interface will not work as browsers do not allow opening TCP sockets.  \nYou still need to instruct the compiler to ignore node dependencies. For webpack, it can be done like this:\n\n```bash\nnew webpack.IgnorePlugin({\n  resourceRegExp: /^fs$|^net$/,\n}),\n```\n\n## Features\n\n```js\nconst { ThermalPrinter, PrinterTypes, CharacterSet, BreakLine } = require('node-thermal-printer');\n\nlet printer = new ThermalPrinter({\n  type: PrinterTypes.STAR,                                  // Printer type: 'star' or 'epson'\n  interface: 'tcp://xxx.xxx.xxx.xxx',                       // Printer interface\n  characterSet: CharacterSet.PC852_LATIN2,                  // Printer character set\n  removeSpecialCharacters: false,                           // Removes special characters - default: false\n  lineCharacter: \"=\",                                       // Set character for lines - default: \"-\"\n  breakLine: BreakLine.WORD,                                // Break line after WORD or CHARACTERS. Disabled with NONE - default: WORD\n  options:{                                                 // Additional options\n    timeout: 5000                                           // Connection timeout (ms) [applicable only for network printers] - default: 3000\n  }\n});\n\nlet isConnected = await printer.isPrinterConnected();       // Check if printer is connected, return bool of status\nlet execute = await printer.execute();                      // Executes all the commands. Returns success or throws error\nlet raw = await printer.raw(Buffer.from(\"Hello world\"));    // Print instantly. Returns success or throws error\nprinter.print(\"Hello World\");                               // Append text\nprinter.println(\"Hello World\");                             // Append text with new line\nprinter.openCashDrawer();                                   // Kick the cash drawer\nprinter.cut();                                              // Cuts the paper (if printer only supports one mode use this)\nprinter.partialCut();                                       // Cuts the paper leaving a small bridge in middle (if printer supports multiple cut modes)\nprinter.beep();                                             // Sound internal beeper/buzzer (if available)\nprinter.upsideDown(true);                                   // Content is printed upside down (rotated 180 degrees)\nprinter.setCharacterSet(CharacterSet.PC852_LATIN2);         // Set character set - default set on init\nprinter.setPrinterDriver(Object)                            // Set printer drive - default set on init\n\nprinter.bold(true);                                         // Set text bold\nprinter.invert(true);                                       // Background/text color inversion\nprinter.underline(true);                                    // Underline text (1 dot thickness)\nprinter.underlineThick(true);                               // Underline text with thick line (2 dot thickness)\nprinter.drawLine();                                         // Draws a line\nprinter.newLine();                                          // Inserts break line\n\nprinter.alignCenter();                                      // Align text to center\nprinter.alignLeft();                                        // Align text to left\nprinter.alignRight();                                       // Align text to right\n\nprinter.setTypeFontA();                                     // Set font type to A (default)\nprinter.setTypeFontB();                                     // Set font type to B\n\nprinter.setTextNormal();                                    // Set text to normal\nprinter.setTextDoubleHeight();                              // Set text to double height\nprinter.setTextDoubleWidth();                               // Set text to double width\nprinter.setTextQuadArea();                                  // Set text to quad area\nprinter.setTextSize(7,7);                                   // Set text height (0-7) and width (0-7)\n\nprinter.leftRight(\"Left\", \"Right\");                         // Prints text left and right\nprinter.table([\"One\", \"Two\", \"Three\"]);                     // Prints table equally\nprinter.tableCustom([                                       // Prints table with custom settings (text, align, width, cols, bold)\n  { text:\"Left\", align:\"LEFT\", width:0.5 },\n  { text:\"Center\", align:\"CENTER\", width:0.25, bold:true },\n  { text:\"Right\", align:\"RIGHT\", cols:8 }\n]);\n\nprinter.code128(\"Code128\");                                 // Print code128 bar code\nprinter.printQR(\"QR CODE\");                                 // Print QR code\nawait printer.printImage('./assets/olaii-logo-black.png');  // Print PNG image\n\nprinter.clear();                                              // Clears printText value\nprinter.getText();                                            // Returns printer buffer string value\nprinter.getBuffer();                                          // Returns printer buffer\nprinter.setBuffer(newBuffer);                                 // Set the printer buffer to a copy of newBuffer\nprinter.getWidth();                                           // Get number of characters in one line\n```\n\n## How to run examples (Set to EPSON)\n\nNetwork printer\n\n```bash\nnode examples/example.js tcp://xxx.xxx.xxx.xxx\n```\n\nPrinter name via Printer module\n\n```bash\nnode examples/example.js 'printer:My Printer'\n```\n\nLocal port or file\n\n```bash\nnode examples/example.js '\\\\.\\COM1'\n```\n\n## Interface options\n\n| Value | Description |\n|---------------------------|------------|\n| `tcp://192.168.0.99:9100` | Network printer with port |\n| `printer:auto`            | Auto select raw system printer via [Printer](https://www.npmjs.com/package/printer) or [Electron printer](https://www.npmjs.com/package/electron-printer) module |\n| `printer:My Printer Name` | Select system printer by name via [Printer](https://www.npmjs.com/package/printer) or [Electron printer](https://www.npmjs.com/package/electron-printer) module |\n| `\\\\.\\COM1`                | Print via local port or file |\n\n### System Printer Drivers\n\nWhen using a system printer, you need to provide the driver.\nUse electron-printer or printer driver:\n\n```js\nconst ThermalPrinter = require(\"node-thermal-printer\").printer;\nconst PrinterTypes = require(\"node-thermal-printer\").types;\nconst electron = typeof process !== 'undefined' \u0026\u0026 process.versions \u0026\u0026 !!process.versions.electron;\n\nlet printer = new ThermalPrinter({\n  type: PrinterTypes.EPSON,\n  interface: 'printer:My Printer',\n  driver: require(electron ? 'electron-printer' : 'printer')\n});\n```\n\nUse a custom printer driver:\n\n```js\nconst ThermalPrinter = require(\"node-thermal-printer\").printer;\nconst PrinterTypes = require(\"node-thermal-printer\").types;\n\nlet printer = new ThermalPrinter({\n  type: PrinterTypes.EPSON,\n  interface: 'printer:My Printer',\n  driver: MyCustomDriver\n});\n\n// you can also set the driver after init:\nprinter.setPrinterDriver(MyCustomDriver)\n```\n\n### Network printing example\n\n```js\nconst ThermalPrinter = require(\"node-thermal-printer\").printer;\nconst PrinterTypes = require(\"node-thermal-printer\").types;\n\nlet printer = new ThermalPrinter({\n  type: PrinterTypes.EPSON,\n  interface: 'tcp://xxx.xxx.xxx.xxx'\n});\n\nprinter.alignCenter();\nprinter.println(\"Hello world\");\nawait printer.printImage('./assets/olaii-logo-black.png')\nprinter.cut();\n\ntry {\n  let execute = printer.execute()\n  console.log(\"Print done!\");\n} catch (error) {\n  console.error(\"Print failed:\", error);\n}\n```\n\n## 2D Barcode Examples\n\nExample settings are the default when not specified.\n\n```js\nprinter.code128(\"Code128\", {\n    width: \"LARGE\",          // \"SMALL\", \"MEDIUM\", \"LARGE\",\n    height: 80,              // 50 \u003c x \u003c 80\n    text: 2                  // 1 - No text\n                             // 2 - Text on bottom\n                             // 3 - No text inline\n                             // 4 - Text on bottom inline\n});\n\nprinter.printQR(\"QR Code\", {\n    cellSize: 3,             // 1 - 8\n    correction: 'M',         // L(7%), M(15%), Q(25%), H(30%)\n    model: 2                 // 1 - Model 1\n                             // 2 - Model 2 (standard)\n                             // 3 - Micro QR\n});\n\nprinter.pdf417(\"PDF417\", {\n    rowHeight: 3,            // 2 - 8\n    width: 3,                // 2 - 8\n    correction: 1,           // Ratio: 1 - 40\n    truncated: false,        // boolean\n    columns: 0               // 1 - 30, 0 auto\n});\n\nprinter.maxiCode(\"MaxiCode\", {\n    mode: 4,                 // 2 - Formatted/structured Carrier Message (US)\n                             // 3 - Formatted/structured Carrier Message (International)\n                             // 4 - Unformatted data with Standard Error Correction.\n                             // 5 - Unformatted data with Enhanced Error Correction.\n                             // 6 - For programming hardware devices.\n});\n```\n\n## 1D Barcode Example\n\n```js\nvar data = \"GS1-128\"     // Barcode data (string or buffer)\nvar type = 74            // Barcode type (See Reference)\nvar settings = {         // Optional Settings\n  hriPos: 0,             // Human readable character 0 - 3 (none, top, bottom, both)\n  hriFont: 0,            // Human readable character font\n  width: 3,              // Barcode width\n  height: 168            // Barcode height\n}\n\nprinter.printBarcode(data, type, settings);\n```\n\n---\n\n### Epson Barcode Reference\n\n|  # | Type                         | Possible Characters                                                                      | Length of Data         |\n|:--:|------------------------------|------------------------------------------------------------------------------------------|------------------------|\n| 65 | UPC-A                        | 0 - 9                                                                                    | 11, 12                 |\n| 66 | UPC-E                        | 0 - 9                                                                                    | 6 – 8, 11, 12          |\n| 67 | JAN13                        | 0 - 9                                                                                    | 12, 13                 |\n| 68 | JAN8                         | 0 - 9                                                                                    | 7, 8                   |\n| 69 | Code39                       | 0 – 9, A – Z, SP, $, %, *, +, -, ., /                                                    | 1 – 255                |\n| 70 | ITF (Interleaved 2 of 5)     | 0 – 9                                                                                    | 2 – 254  (even number) |\n| 71 | CODABAR  (NW-7)              | 0 – 9, A – D, a – d, $, +, −, ., /, :                                                    | 2 – 255                |\n| 72 | CODE93                       | 00h – 7Fh                                                                                | 1 – 255                |\n| 73 | CODE128                      | 00h – 7Fh                                                                                | 2 - 255                |\n| 74 | GS1-128                      | NUL – SP(7Fh)                                                                            | 2 – 255                |\n| 75 | GS1 DataBar  Omnidirectional | 0 – 9                                                                                    | 13                     |\n| 76 | GS1 DataBar  Truncated       | 0 – 9                                                                                    | 13                     |\n| 77 | GS1 DataBar  Limited         | 0 – 9                                                                                    | 13                     |\n| 78 | GS1 DataBar  Expanded        | 0 – 9, A – D, a – d, SP, !,  \", %, $, ', (, ), *, +, ,, -, .,  /, :, ;, \u003c, =, \u003e, ?, _, { | 2 - 255                |\n\n---\n\n## STAR Barcode Reference\n\n```js\nvar data = \"TEST\"        // Barcode data (string or buffer)\nvar type = 7             // Barcode type (See Reference)\nvar settings = {         // Optional Settings\n  characters: 1,         // Add characters (See Reference)\n  mode: 3,               // Barcode mode (See Reference)\n  height: 150,           // Barcode height (0≤ height ≤255)\n}\n\nprinter.printBarcode(data, type, settings);\n```\n\n### Type\n\n| # | Type      |\n|:-:|-----------|\n| 0 | UPC-E     |\n| 1 | UPC-A     |\n| 2 | JAN/EAN8  |\n| 3 | JAN/EAN13 |\n| 4 | Code39    |\n| 5 | ITF       |\n| 6 | CODE128   |\n| 7 | CODE93    |\n| 8 | NW-7      |\n\n### Settings characters\n\n| # | Description                                                                         |\n|:-:|-------------------------------------------------------------------------------------|\n| 1 | No added under-bar characters. Executes line feed after printing a bar code         |\n| 2 | Adds under-bar characters. Executes line feed after printing a bar code             |\n| 3 | No added under-bar characters. Does not execute line feed after printing a bar code |\n| 4 | Adds under-bar characters. Does not execute line feed after printing a bar code     |\n\n### Settings mode\n\n| # | UPC-E, UPC-A, JAN/EAN8, JAN/EAN13, Code128, Code93  | Code39, NW-7             | ITF                       |\n|:-:|-----------------------------------------------------|--------------------------|---------------------------|\n| 1 | Minimum module 2 dots                               | Narrow: Wide = 2:6 dots  | Narrow: Wide = 2:5 dots   |\n| 2 | Minimum module 3 dots                               | Narrow: Wide = 3:9 dots  | Narrow: Wide = 4:10 dots  |\n| 3 | Minimum module 4 dots                               | Narrow: Wide = 4:12 dots | Narrow: Wide = 6:15 dots  |\n| 4 |                                                     | Narrow: Wide = 2:5 dots  | Narrow: Wide = 2:4 dots   |\n| 5 |                                                     | Narrow: Wide = 3:8 dots  | Narrow: Wide = 4:8 dots   |\n| 6 |                                                     | Narrow: Wide = 4:10 dots | Narrow: Wide = 6:12 dots  |\n| 7 |                                                     | Narrow: Wide = 2:4 dots  | Narrow: Wide = 2:6 dots   |\n| 8 |                                                     | Narrow: Wide = 3:6 dots  | Narrow: Wide = 3:9 dots   |\n| 9 |                                                     | Narrow: Wide = 4:8 dots  | Narrow: Wide = 4:12 dots  |\n\n---\n\n## Docs\n\n- STAR: \u003chttp://www.starmicronics.com/support/mannualfolder/starline_cm_rev1.15_en.pdf\u003e\n- EPSON: \u003chttps://reference.epson-biz.com/modules/ref_escpos/index.php\u003e\n\n## Tested printers\n\n- Star TSP700\n- Rongta RP80US\n- Rongta RP326-USE\n- EPSON TM-T88V\n- EPSON TM-T20X\n- EPSON TM-T82IIIL\n- Posman BTP-R880NP (Type \"epson\")\n- Brother TD-4550DNWB\n- Daruma DR800\n\n## Character sets\n\n- PC437_USA\n- PC850_MULTILINGUAL\n- PC860_PORTUGUESE\n- PC863_CANADIAN_FRENCH\n- PC865_NORDIC\n- PC851_GREEK\n- PC857_TURKISH\n- PC737_GREEK\n- ISO8859_7_GREEK\n- WPC1252\n- PC866_CYRILLIC2\n- PC852_LATIN2\n- SLOVENIA\n- PC858_EURO\n- WPC775_BALTIC_RIM\n- PC855_CYRILLIC\n- PC861_ICELANDIC\n- PC862_HEBREW\n- PC864_ARABIC\n- PC869_GREEK\n- ISO8859_2_LATIN2\n- ISO8859_15_LATIN9\n- PC1125_UKRANIAN\n- WPC1250_LATIN2\n- WPC1251_CYRILLIC\n- WPC1253_GREEK\n- WPC1254_TURKISH\n- WPC1255_HEBREW\n- WPC1256_ARABIC\n- WPC1257_BALTIC_RIM\n- WPC1258_VIETNAMESE\n- KZ1048_KAZAKHSTAN\n\n## CHANGELOG\n\nSee [CHANGELOG.md](./CHANGELOG.md)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKlemen1337%2Fnode-thermal-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKlemen1337%2Fnode-thermal-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKlemen1337%2Fnode-thermal-printer/lists"}