{"_id":"@deniz073/system-receipt-printer","name":"@deniz073/system-receipt-printer","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.1":{"name":"@deniz073/system-receipt-printer","version":"2.0.1","type":"module","exports":{"import":"./dist/system-receipt-printer.mjs","require":"./dist/system-receipt-printer.cjs"},"module":"dist/system-receipt-printer.mjs","main":"dist/system-receipt-printer.cjs","repository":{"type":"git","url":"git+https://github.com/NielsLeenheer/SystemReceiptPrinter.git"},"keywords":["receipt","printerdriver","printer","escpos","star","epson"],"author":{"name":"Niels Leenheer"},"license":"MIT","bugs":{"url":"https://github.com/NielsLeenheer/NetworkReceiptPrinter/issues"},"homepage":"https://github.com/NielsLeenheer/NetworkReceiptPrinter#readme","devDependencies":{"@rollup/plugin-node-resolve":"^15.0.2","rollup":"^3.20.7"},"scripts":{"build":"rollup -c","dev":"rollup -c -w"},"dependencies":{"@grandchef/node-printer":"^0.8.0","@mapbox/node-pre-gyp":"^1.0.11"},"_id":"@deniz073/system-receipt-printer@2.0.1","gitHead":"ee4b204894782e10a57e4be5f0c6d4ed3949ad9f","description":"This is an library that allows you to print to a receipt printer using the system printer driver.","_nodeVersion":"18.18.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-79xsc6A2mp8ql5f+6jNvFN4ZItsyp6DAvUy2wLnCHiITVIbaDDXYldKIGlptVACcfPyfDH088NFyagkiulAXKQ==","shasum":"daafb5b878a16b0fda85554e2050a3c424d8fac7","tarball":"https://registry.npmjs.org/@deniz073/system-receipt-printer/-/system-receipt-printer-2.0.1.tgz","fileCount":5,"unpackedSize":9675,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDIih/Q4SgAbAZ/nJh+xdGycQeCM3eOKYHBd5R5gVVSuAIgKuKhHSzRxZty7v55tC9QLlg/z+OkPUwv3dmoiFCfRQo="}]},"_npmUser":{"name":"deniz073","email":"denizerdem18@gmail.com"},"directories":{},"maintainers":[{"name":"deniz073","email":"denizerdem18@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/system-receipt-printer_2.0.1_1729954361871_0.6659059847565973"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-26T14:52:41.757Z","2.0.1":"2024-10-26T14:52:42.047Z","modified":"2024-10-26T14:52:42.324Z"},"maintainers":[{"name":"deniz073","email":"denizerdem18@gmail.com"}],"description":"This is an library that allows you to print to a receipt printer using the system printer driver.","homepage":"https://github.com/NielsLeenheer/NetworkReceiptPrinter#readme","keywords":["receipt","printerdriver","printer","escpos","star","epson"],"repository":{"type":"git","url":"git+https://github.com/NielsLeenheer/SystemReceiptPrinter.git"},"author":{"name":"Niels Leenheer"},"bugs":{"url":"https://github.com/NielsLeenheer/NetworkReceiptPrinter/issues"},"license":"MIT","readme":"# SystemReceiptPrinter\r\n\r\nThis is an library that allows you to print to a receipt printer using the system printer driver.\r\n\r\n<br>\r\n\r\n[![npm](https://img.shields.io/npm/v/@point-of-sale/system-receipt-printer)](https://www.npmjs.com/@point-of-sale/system-receipt-printer)\r\n![GitHub License](https://img.shields.io/github/license/NielsLeenheer/SystemReceiptPrinter)\r\n\r\n\r\n> This library is part of [@point-of-sale](https://point-of-sale.dev), a collection of libraries for interfacing browsers and Node with Point of Sale devices such as receipt printers, barcode scanners and customer facing displays.\r\n\r\n<br>\r\n\r\n## What does this library do?\r\n\r\nIn order to print a receipt on a receipt printer you need to build the receipt and encode it as in the ESC/POS or StarPRNT language. You can use the [`ReceiptPrinterEncoder`](https://github.com/NielsLeenheer/ReceiptPrinterEncoder) library for this. You end up with an array of raw bytes that needs to be send to the printer. One way to do that is using the system printer driver.\r\n\r\n<br>\r\n\r\n## Installation\r\n\r\nIf you want to use this libary, first install the package using npm:\r\n\r\n```\r\nnpm install @point-of-sale/system-receipt-printer --save\r\n```\r\n\r\nIn your project you can then import it, if you use ES6 modules:\r\n\r\n```js\r\nimport SystemReceiptPrinter from '@point-of-sale/system-receipt-printer';\r\n\r\nlet receiptPrinter = new SystemReceiptPrinter();\r\n```\r\n\r\nOr require it, if you are using CommonJS:\r\n\r\n```js\r\nlet SystemReceiptPrinter = require('@point-of-sale/system-receipt-printer');\r\n\r\nlet receiptPrinter = new SystemReceiptPrinter();\r\n```\r\n\r\n<br>\r\n\r\n## Configuration\r\n\r\nWhen you create the `SystemReceiptPrinter` object you can specify a number of options to help with the library with connecting to the device. \r\n\r\n### Printer settings\r\n\r\nWhen a printer is connected to your system, it will get assigned a unique name. Provide that name when you instantiate the `SystemReceiptPrinter` object:\r\n\r\n- `name`<br>\r\n    The name of the printer.\r\n\r\n<br>\r\n\r\nFor example, to print on the printer `Star_TSP143__STR_T_001_`:\r\n\r\n```js\r\nconst receiptPrinter = new SystemReceiptPrinter({ \r\n    name:   'Star_TSP143__STR_T_001_'\r\n});\r\n```\r\n\r\n<br>\r\n\r\n## Connect to a receipt printer\r\n\r\nThe actually connect to the printer you need to call the `connect()` function. To find out when a receipt printer is connected you can listen for the `connected` event using the `addEventListener()` function.\r\n\r\n```js\r\nreceiptPrinter.addEventListener('connected', device => {\r\n    console.log(`Connected to printer`);\r\n});\r\n```\r\n\r\nThe callback of the `connected` event is passed an object with the following properties:\r\n\r\n-   `type`<br>\r\n    Type of the connection that is used, in this case it is always `system`.\r\n\r\n<br>\r\n\r\n## Commands\r\n\r\nOnce connected you can use the following command to print receipts.\r\n\r\n### Printing receipts\r\n\r\nWhen you want to print a receipt, you can call the `print()` function with an array, or a typed array with bytes. The data must be properly encoded for the printer. \r\n\r\nFor example:\r\n\r\n```js\r\n/* Encode the receipt */\r\n\r\nlet encoder = new ReceiptPrinterEncoder({\r\n    language:  'esc-pos',\r\n    codepageMapping: 'epson'\r\n});\r\n\r\nlet data = encoder\r\n    .initialize()\r\n    .text('The quick brown fox jumps over the lazy dog')\r\n    .newline()\r\n    .qrcode('https://nielsleenheer.com')\r\n    .encode();\r\n\r\n/* Print the receipt */\r\n\r\nreceiptPrinter.print(data);\r\n```\r\n\r\n### Disconnect from the printer \r\n\r\nWhen you are done with printing, you can call the `disconnect()` function. This will terminate the connection to the printer. If the connection to the printer is closed, the library will emit a `disconnected` event.\r\n\r\n```js\r\nreceiptPrinter.addEventListener('disconnected', () => {\r\n    console.log(`Disconnected from the printer`);\r\n});\r\n\r\nreceiptPrinter.disconnect();\r\n```\r\n\r\n### Find all printers\r\n\r\nThe `SystemReceiptPrinter` object has a static function that you can call to get a list of all printers that are available on your system:\r\n\r\n```js\r\nlet printers = SystemReceiptPrinter.getPrinters();\r\n\r\n[\r\n    {\r\n        name: 'Star_TSP143__STR_T_001_',\r\n        isDefault: false,\r\n        options: { ... },\r\n        status: 'IDLE'\r\n    }, \r\n\r\n    {\r\n        name: 'Star_TSP654__STR_T_001_',\r\n        isDefault: false,\r\n        options: { ... },\r\n        status: 'IDLE'\r\n    }\r\n]\r\n```\r\n\r\n<br>\r\n\r\n-----\r\n\r\n<br>\r\n\r\nThis library has been created by Niels Leenheer under the [MIT license](LICENSE). Feel free to use it in your products. The  development of this library is sponsored by Salonhub.\r\n\r\n<a href=\"https://salohub.nl\"><img src=\"https://salonhub.nl/assets/images/salonhub.svg\" width=140></a>\r\n","readmeFilename":"README.md"}