{"_id":"@allyyssoonnn/node-thermal-printer","name":"@allyyssoonnn/node-thermal-printer","dist-tags":{"latest":"4.1.2"},"versions":{"4.1.2":{"name":"@allyyssoonnn/node-thermal-printer","version":"4.1.2","description":"Print on Epson, Tanca and Star thermal printers with NodeJS","main":"node-thermal-printer.js","repository":{"type":"git","url":"git+https://github.com/Klemen1337/node-thermal-printer.git"},"keywords":["thermal printer","thermal","printer","epson","star"],"author":{"name":"Klemen Kastelic","email":"klemen.kast@gmail.com","url":"http://kastelic.net/"},"license":"ISC","bugs":{"url":"https://github.com/Klemen1337/node-thermal-printer/issues"},"homepage":"https://github.com/Klemen1337/node-thermal-printer","dependencies":{"iconv-lite":"0.5.0","pngjs":"3.3.3","unorm":"1.4.1","write-file-queue":"0.0.1"},"devDependencies":{"@types/node":"^10.14.2"},"types":"./node-thermal-printer.d.ts","gitHead":"468a75711d7a664efd54a03e3336a2c9fba36571","_id":"@allyyssoonnn/node-thermal-printer@4.1.2","_nodeVersion":"16.17.1","_npmVersion":"8.15.0","dist":{"integrity":"sha512-LGotIFIXpQkQxXtZQt4sHUYgDEnSPhC6UE8cMnbR+uiRpzjUXP7AUMhzPnAF6D7f9TZ9pJat5YxLvA4nI49zAA==","shasum":"ebdc1b2e3b4e9dbdf0b2bf7d59dfc13bfad50c5c","tarball":"https://registry.npmjs.org/@allyyssoonnn/node-thermal-printer/-/node-thermal-printer-4.1.2.tgz","fileCount":33,"unpackedSize":164310,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICAMR/pMydrnNXkig6qp1HtpyXRHw7agYbvfb6CPS6xeAiAH2mLV6e+habTinIYuBXwH4qq5zRlWLm6ko8FpNIr3Bg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqoXNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmogGA/5AJ2AHbRdnFGeMz/ORlwLPIQbIQ9elGq56xWyrm/0RN+utygC\r\nrySADV0DVEaHNdbbnkhKF4ZQekzaSpodVskwwSGnh8/FO2Ihl+lVuxX1g78R\r\n6hVTecUCKkaElsahX1j5iSM+//K9qhsuomAXo5T1S6XQs2hX8dsaOGUp2tqx\r\noaIeuBex7oyV35xQygTWvfSkvHDp4qTpb4ixFIweQHLZ3QV3yfJG8O9ZLbtH\r\nTU5VPRUBizyIIkSugEOKN/eA53vfDOfLJRCcrCJGZhdy+WOeM1rY46VohZgX\r\nKoOFnJ+aIWZ0KPBY1DN7DFHb6YZkS025gr8DOZBvYguaYRCDr5AurDySaQBn\r\nZfBCaiYKKXWEHqZ/0UYflf/GGZSkIDzNnKcISq3hEi5OZt2ThMNfJaeG3ovg\r\nbxMtecigHXe/raqiXx6ufykqXZ30zZz9VbjP8zH4Jip+Leh6Vkk14T6XByUw\r\nDPF5XfKI3PoItyC1WDEKRczElrdGJZSLXifMOReR24ySbIgu5RWiNVbHblz1\r\nBbgjF4KwEbVvocYJYaNfiVCzk3SMim3TuV/SAx5psIhjLeFw5UO1PeqcJUfy\r\nboV14uQD7VwFN3DvXTGu7wNxAX/oGfNqeml4/UbaecFjKYc0O3f8jk2FvEY2\r\nBW7IXWh5+3+R4Dg87+ifi7n33nmckq/5KWo=\r\n=CcTt\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"allyyssoonnn","email":"alysonone123@gmail.com"},"directories":{},"maintainers":[{"name":"allyyssoonnn","email":"alysonone123@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-thermal-printer_4.1.2_1672119757303_0.8417745443362079"},"_hasShrinkwrap":false}},"time":{"created":"2022-12-27T05:42:37.246Z","4.1.2":"2022-12-27T05:42:37.544Z","modified":"2022-12-27T05:42:37.704Z"},"maintainers":[{"name":"allyyssoonnn","email":"alysonone123@gmail.com"}],"description":"Print on Epson, Tanca and Star thermal printers with NodeJS","homepage":"https://github.com/Klemen1337/node-thermal-printer","keywords":["thermal printer","thermal","printer","epson","star"],"repository":{"type":"git","url":"git+https://github.com/Klemen1337/node-thermal-printer.git"},"author":{"name":"Klemen Kastelic","email":"klemen.kast@gmail.com","url":"http://kastelic.net/"},"bugs":{"url":"https://github.com/Klemen1337/node-thermal-printer/issues"},"license":"ISC","readme":"# Node Thermal Printer\r\nNode.js module for EPSON, Tanca and STAR thermal printers command line printing.\r\n\r\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&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\r\n\r\n\r\n### Installation\r\n```bash\r\n$ npm install node-thermal-printer\r\n```\r\n\r\n\r\n#### Linux specific\r\nLinux requires build-essentials\r\n```bash\r\nsudo apt-get install build-essential\r\n```\r\n\r\n\r\n### Features\r\n```js\r\nconst ThermalPrinter = require(\"../node-thermal-printer\").printer;\r\nconst PrinterTypes = require(\"../node-thermal-printer\").types;\r\n\r\nlet printer = new ThermalPrinter({\r\n  type: PrinterTypes.STAR,                                  // Printer type: 'star' or 'epson'\r\n  interface: 'tcp://xxx.xxx.xxx.xxx',                       // Printer interface\r\n  characterSet: 'SLOVENIA',                                 // Printer character set - default: SLOVENIA\r\n  removeSpecialCharacters: false,                           // Removes special characters - default: false\r\n  lineCharacter: \"=\",                                       // Set character for lines - default: \"-\"\r\n  options:{                                                 // Additional options\r\n    timeout: 5000                                           // Connection timeout (ms) [applicable only for network printers] - default: 3000\r\n  }\r\n});\r\n\r\nlet isConnected = await printer.isPrinterConnected();       // Check if printer is connected, return bool of status\r\nlet execute = await printer.execute();                      // Executes all the commands. Returns success or throws error\r\nlet raw = await printer.raw(Buffer.from(\"Hello world\"));    // Print instantly. Returns success or throws error\r\nprinter.print(\"Hello World\");                               // Append text\r\nprinter.println(\"Hello World\");                             // Append text with new line\r\nprinter.openCashDrawer();                                   // Kick the cash drawer\r\nprinter.cut();                                              // Cuts the paper (if printer only supports one mode use this)\r\nprinter.partialCut();                                       // Cuts the paper leaving a small bridge in middle (if printer supports multiple cut modes)\r\nprinter.beep();                                             // Sound internal beeper/buzzer (if available)\r\nprinter.upsideDown(true);                                   // Content is printed upside down (rotated 180 degrees)\r\nprinter.setCharacterSet(\"SLOVENIA\");                        // Set character set - default set on init\r\nprinter.setPrinterDriver(Object)                            // Set printer drive - default set on init\r\n\r\nprinter.bold(true);                                         // Set text bold\r\nprinter.invert(true);                                       // Background/text color inversion\r\nprinter.underline(true);                                    // Underline text (1 dot thickness)\r\nprinter.underlineThick(true);                               // Underline text with thick line (2 dot thickness)\r\nprinter.drawLine();                                         // Draws a line\r\nprinter.newLine();                                          // Insers break line\r\n\r\nprinter.alignCenter();                                      // Align text to center\r\nprinter.alignLeft();                                        // Align text to left\r\nprinter.alignRight();                                       // Align text to right\r\n\r\nprinter.setTypeFontA();                                     // Set font type to A (default)\r\nprinter.setTypeFontB();                                     // Set font type to B\r\n\r\nprinter.setTextNormal();                                    // Set text to normal\r\nprinter.setTextDoubleHeight();                              // Set text to double height\r\nprinter.setTextDoubleWidth();                               // Set text to double width\r\nprinter.setTextQuadArea();                                  // Set text to quad area\r\nprinter.setTextSize(7,7);                                   // Set text height (0-7) and width (0-7)\r\n\r\nprinter.leftRight(\"Left\", \"Right\");                         // Prints text left and right\r\nprinter.table([\"One\", \"Two\", \"Three\"]);                     // Prints table equaly\r\nprinter.tableCustom([                                       // Prints table with custom settings (text, align, width, cols, bold)\r\n  { text:\"Left\", align:\"LEFT\", width:0.5 },\r\n  { text:\"Center\", align:\"CENTER\", width:0.25, bold:true },\r\n  { text:\"Right\", align:\"RIGHT\", cols:8 }\r\n]);\r\n\r\nprinter.code128(\"Code128\");                                 // Print code128 bar code\r\nprinter.printQR(\"QR CODE\");                                 // Print QR code\r\nawait printer.printImage('./assets/olaii-logo-black.png');  // Print PNG image\r\n\r\nprinter.clear();                                              // Clears printText value\r\nprinter.getText();                                            // Returns printer buffer string value\r\nprinter.getBuffer();                                          // Returns printer buffer\r\nprinter.setBuffer(newBuffer);                                 // Set the printer buffer to a copy of newBuffer\r\nprinter.getWidth();                                           // Get number of characters in one line\r\n```\r\n\r\n### How to run examples (Set to EPSON)\r\nNetwork printer\r\n```bash\r\nnode examples/example.js tcp://xxx.xxx.xxx.xxx\r\n```\r\nPritner name via Printer module\r\n```bash\r\nnode examples/example.js 'printer:My Printer'\r\n```\r\nLocal port or file\r\n```bash\r\nnode examples/example.js '\\\\.\\COM1'\r\n```\r\n\r\n\r\n### Interface options\r\n| Value | Descripton |\r\n|---------------------------|------------|\r\n| `tcp://192.168.0.99:9100` | Network printer with port |\r\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 |\r\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 |\r\n| `\\\\.\\COM1`                | Print via local port or file |\r\n\r\n\r\n#### System Printer Drivers\r\nWhen using a system printer, you need to provide the driver.\r\nUse electron-printer or printer driver:\r\n```js\r\nconst ThermalPrinter = require(\"node-thermal-printer\").printer;\r\nconst PrinterTypes = require(\"node-thermal-printer\").types;\r\nconst electron = typeof process !== 'undefined' && process.versions && !!process.versions.electron;\r\n\r\nlet printer = new ThermalPrinter({\r\n  type: PrinterTypes.EPSON,\r\n  interface: 'printer:My Printer',\r\n  driver: require(electron ? 'electron-printer' : 'printer')\r\n});\r\n```\r\n\r\nUse a custom printer driver:\r\n```js\r\nconst ThermalPrinter = require(\"node-thermal-printer\").printer;\r\nconst PrinterTypes = require(\"node-thermal-printer\").types;\r\n\r\nlet printer = new ThermalPrinter({\r\n  type: PrinterTypes.EPSON,\r\n  interface: 'printer:My Printer',\r\n  driver: MyCustomDriver\r\n});\r\n\r\n// you can also set the driver after init:\r\nprinter.setPrinterDriver(MyCustomDriver)\r\n```\r\n\r\n### Network printing example\r\n```js\r\nconst ThermalPrinter = require(\"node-thermal-printer\").printer;\r\nconst PrinterTypes = require(\"node-thermal-printer\").types;\r\n\r\nlet printer = new ThermalPrinter({\r\n  type: PrinterTypes.EPSON,\r\n  interface: 'tcp://xxx.xxx.xxx.xxx'\r\n});\r\n\r\nprinter.alignCenter();\r\nprinter.println(\"Hello world\");\r\nawait printer.printImage('./assets/olaii-logo-black.png')\r\nprinter.cut();\r\n\r\ntry {\r\n  let execute = printer.execute()\r\n  console.error(\"Print done!\");\r\n} catch (error) {\r\n  console.log(\"Print failed:\", error);\r\n}\r\n```\r\n\r\n\r\n### 2D Barcode Examples\r\nExample settings are the default when not specified.\r\n\r\n```js\r\nprinter.code128(\"Code128\", {\r\n    width: \"LARGE\",          // \"SMALL\", \"MEDIUM\", \"LARGE\",\r\n    height: 80,              // 50 < x < 80\r\n    text: 2                  // 1 - No text\r\n                             // 2 - Text on bottom\r\n                             // 3 - No text inline\r\n                             // 4 - Text on bottom inline\r\n});\r\n\r\nprinter.printQR(\"QR Code\", {\r\n    cellSize: 3,             // 1 - 8\r\n    correction: 'M',         // L(7%), M(15%), Q(25%), H(30%)\r\n    model: 2                 // 1 - Model 1\r\n                             // 2 - Model 2 (standard)\r\n                             // 3 - Micro QR\r\n});\r\n\r\nprinter.pdf417(\"PDF417\", {\r\n    rowHeight: 3,            // 2 - 8\r\n    width: 3,                // 2 - 8\r\n    correction: 1,           // Ratio: 1 - 40\r\n    truncated: false,        // boolean\r\n    columns: 0               // 1 - 30, 0 auto\r\n});\r\n\r\nprinter.maxiCode(\"MaxiCode\", {\r\n    mode: 4,                 // 2 - Formatted/structured Carrier Message (US)\r\n                             // 3 - Formatted/structured Carrier Message (International)\r\n                             // 4 - Unformatted data with Standard Error Correction.\r\n                             // 5 - Unformatted data with Enhanced Error Correction.\r\n                             // 6 - For programming hardware devices.\r\n});\r\n```\r\n\r\n\r\n### 1D Barcode Example\r\n```js\r\nvar data = \"GS1-128\"     // Barcode data (string or buffer)\r\nvar type = 74            // Barcode type (See Reference)\r\nvar settings = {         // Optional Settings\r\n  hriPos: 0,             // Human readable character 0 - 3 (none, top, bottom, both)\r\n  hriFont: 0,            // Human readable character font\r\n  width: 3,              // Barcode width\r\n  height: 168            // Barcode height\r\n}\r\n\r\nprinter.printBarcode(data, type, settings);\r\n```\r\n\r\n---\r\n\r\n### Epson Barcode Reference\r\n|  # | Type                         | Possible Characters                                                                      | Length of Data         |\r\n|:--:|------------------------------|------------------------------------------------------------------------------------------|------------------------|\r\n| 65 | UPC-A                        | 0 - 9                                                                                    | 11, 12                 |\r\n| 66 | UPC-E                        | 0 - 9                                                                                    | 6 – 8, 11, 12          |\r\n| 67 | JAN13                        | 0 - 9                                                                                    | 12, 13                 |\r\n| 68 | JAN8                         | 0 - 9                                                                                    | 7, 8                   |\r\n| 69 | Code39                       | 0 – 9, A – Z, SP, $, %, *, +, -, ., /                                                    | 1 – 255                |\r\n| 70 | ITF (Interleaved 2 of 5)     | 0 – 9                                                                                    | 2 – 254  (even number) |\r\n| 71 | CODABAR  (NW-7)              | 0 – 9, A – D, a – d, $, +, −, ., /, :                                                    | 2 – 255                |\r\n| 72 | CODE93                       | 00h – 7Fh                                                                                | 1 – 255                |\r\n| 73 | CODE128                      | 00h – 7Fh                                                                                | 2 - 255                |\r\n| 74 | GS1-128                      | NUL – SP(7Fh)                                                                            | 2 – 255                |\r\n| 75 | GS1 DataBar  Omnidirectional | 0 – 9                                                                                    | 13                     |\r\n| 76 | GS1 DataBar  Truncated       | 0 – 9                                                                                    | 13                     |\r\n| 77 | GS1 DataBar  Limited         | 0 – 9                                                                                    | 13                     |\r\n| 78 | GS1 DataBar  Expanded        | 0 – 9, A – D, a – d, SP, !,  \", %, $, ', (, ), *, +, ,, -, .,  /, :, ;, <, =, >, ?, _, { | 2 - 255                |\r\n\r\n---\r\n\r\n### STAR Barcode Reference\r\n```js\r\nvar data = \"TEST\"        // Barcode data (string or buffer)\r\nvar type = 7             // Barcode type (See Reference)\r\nvar settings = {         // Optional Settings\r\n  characters: 1,         // Add characters (See Reference)\r\n  mode: 3,               // Barcode mode (See Reference)\r\n  height: 150,           // Barcode height (0≤ height ≤255)\r\n}\r\n\r\nprinter.printBarcode(data, type, settings);\r\n```\r\n\r\n### Type\r\n| # | Type      |\r\n|:-:|-----------|\r\n| 0 | UPC-E     |\r\n| 1 | UPC-A     |\r\n| 2 | JAN/EAN8  |\r\n| 3 | JAN/EAN13 |\r\n| 4 | Code39    |\r\n| 5 | ITF       |\r\n| 6 | CODE128   |\r\n| 7 | CODE93    |\r\n| 8 | NW-7      |\r\n\r\n#### Settings characters\r\n| # | Description                                                                         |\r\n|:-:|-------------------------------------------------------------------------------------|\r\n| 1 | No added under-bar characters. Executes line feed after printing a bar code         |\r\n| 2 | Adds under-bar characters. Executes line feed after printing a bar code             |\r\n| 3 | No added under-bar characters. Does not execute line feed after printing a bar code |\r\n| 4 | Adds under-bar characters. Does not execute line feed after printing a bar code     |\r\n\r\n#### Settings mode\r\n| # | UPC-E, UPC-A, JAN/EAN8, JAN/EAN13, Code128, Code93  | Code39, NW-7             | ITF                       |\r\n|:-:|-----------------------------------------------------|--------------------------|---------------------------|\r\n| 1 | Minimum module 2 dots                               | Narrow: Wide = 2:6 dots  | Narrow: Wide = 2:5 dots   |\r\n| 2 | Minimum module 3 dots                               | Narrow: Wide = 3:9 dots  | Narrow: Wide = 4:10 dots  |\r\n| 3 | Minimum module 4 dots                               | Narrow: Wide = 4:12 dots | Narrow: Wide = 6:15 dots  |\r\n| 4 |                                                     | Narrow: Wide = 2:5 dots  | Narrow: Wide = 2:4 dots   |\r\n| 5 |                                                     | Narrow: Wide = 3:8 dots  | Narrow: Wide = 4:8 dots   |\r\n| 6 |                                                     | Narrow: Wide = 4:10 dots | Narrow: Wide = 6:12 dots  |\r\n| 7 |                                                     | Narrow: Wide = 2:4 dots  | Narrow: Wide = 2:6 dots   |\r\n| 8 |                                                     | Narrow: Wide = 3:6 dots  | Narrow: Wide = 3:9 dots   |\r\n| 9 |                                                     | Narrow: Wide = 4:8 dots  | Narrow: Wide = 4:12 dots  |\r\n\r\n\r\n---\r\n\r\n\r\n### Docs\r\n- STAR: http://www.starmicronics.com/support/mannualfolder/starline_cm_rev1.15_en.pdf\r\n- EPSON: https://reference.epson-biz.com/modules/ref_escpos/index.php\r\n\r\n\r\n### Tested printers:\r\n- Star TSP700\r\n- Rongta RP80US\r\n- Rongta RP326-USE\r\n- EPSON TM-T88V\r\n- Posman BTP-R880NP (Type \"epson\")\r\n- EPSON TM-T20X\r\n- EPSON TM-T82IIIL\r\n\r\n### Character sets\r\n- PC437_USA\r\n- PC850_MULTILINGUAL\r\n- PC860_PORTUGUESE\r\n- PC863_CANADIAN_FRENCH\r\n- PC865_NORDIC\r\n- PC851_GREEK\r\n- PC857_TURKISH\r\n- PC737_GREEK\r\n- ISO8859_7_GREEK\r\n- WPC1252\r\n- PC866_CYRILLIC2\r\n- PC852_LATIN2\r\n- SLOVENIA\r\n- PC858_EURO\r\n- WPC775_BALTIC_RIM\r\n- PC855_CYRILLIC\r\n- PC861_ICELANDIC\r\n- PC862_HEBREW\r\n- PC864_ARABIC\r\n- PC869_GREEK\r\n- ISO8859_2_LATIN2\r\n- ISO8859_15_LATIN9\r\n- PC1125_UKRANIAN\r\n- WPC1250_LATIN2\r\n- WPC1251_CYRILLIC\r\n- WPC1253_GREEK\r\n- WPC1254_TURKISH\r\n- WPC1255_HEBREW\r\n- WPC1256_ARABIC\r\n- WPC1257_BALTIC_RIM\r\n- WPC1258_VIETNAMESE\r\n- KZ1048_KAZAKHSTAN\r\n\r\n\r\n\r\n## CHANGELOG\r\nSee [CHANGELOG.md](./CHANGELOG.md)\r\n","readmeFilename":"README.md"}