{"id":13786010,"url":"https://github.com/Hubertformin/electron-pos-printer","last_synced_at":"2025-05-11T21:32:28.505Z","repository":{"id":38687704,"uuid":"218481027","full_name":"Hubertformin/electron-pos-printer","owner":"Hubertformin","description":"Electron-pos-printer is a plugin that works to ease paper formatting and printing to thermal printers. it currently supports 80mm, 78mm, 76mm, 58mm, 57mm and 44mm printers thermal printers. it is built with Electron.js and Node.js","archived":false,"fork":false,"pushed_at":"2023-05-13T09:01:43.000Z","size":481,"stargazers_count":336,"open_issues_count":37,"forks_count":106,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-09T15:05:10.737Z","etag":null,"topics":["electron-printer","electronjs","nodejs","pos-printers","printer"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hubertformin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-10-30T08:40:34.000Z","updated_at":"2025-05-07T22:49:54.000Z","dependencies_parsed_at":"2024-06-18T17:03:32.273Z","dependency_job_id":"c80fa8f1-f148-4500-80c2-ed31ceccb032","html_url":"https://github.com/Hubertformin/electron-pos-printer","commit_stats":{"total_commits":88,"total_committers":6,"mean_commits":"14.666666666666666","dds":0.1477272727272727,"last_synced_commit":"d01e9614c0cdb056143fbe6172124908878a0a78"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hubertformin%2Felectron-pos-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hubertformin%2Felectron-pos-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hubertformin%2Felectron-pos-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hubertformin%2Felectron-pos-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hubertformin","download_url":"https://codeload.github.com/Hubertformin/electron-pos-printer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253638989,"owners_count":21940434,"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":["electron-printer","electronjs","nodejs","pos-printers","printer"],"created_at":"2024-08-03T19:01:08.031Z","updated_at":"2025-05-11T21:32:24.152Z","avatar_url":"https://github.com/Hubertformin.png","language":"TypeScript","readme":"\n![License](https://img.shields.io/npm/l/electron-pos-printer)\n![Version](https://img.shields.io/npm/v/electron-pos-printer?label=version)\n![Issues](https://img.shields.io/github/issues/Hubertformin/electron-pos-printer)\n\n# Electron-pos-printer\nA customizable electron.js printing plugin specifically designed for thermal receipt printers.\nIt supports 80mm, 78mm, 76mm, 58mm, 57mm, 44mm printers. It currently supports versions of electron \u003e= 6.x.x\n\n### Installation\n```bash\n$ npm install electron-pos-printer\n$ yarn add electron-pos-printer\n```\n### Demo\nCheck out this [Demo](https://github.com/fssonca/electron-printer ) by [fssonca](https://github.com/fssonca)\n\n### Usage\n### In main process\n```js\nconst {PosPrinter} = require(\"electron-pos-printer\");\n```\n### In render process\n```js\nconst {PosPrinter} = require('electron').remote.require(\"electron-pos-printer\");\n```\nElectron \u003e= `v10.x.x`\n```js\nconst {PosPrinter} = require('@electron/remote').remote.require(\"electron-pos-printer\");\n```\n\n### Example code\n```js\nconst {PosPrinter} = require(\"electron-pos-printer\");\nconst path = require(\"path\");\n\nconst options = {\n    preview: false,\n    margin: '0 0 0 0',\n    copies: 1,\n    printerName: 'XP-80C',\n    timeOutPerLine: 400,\n    pageSize: '80mm' // page size\n}\n\nconst data = [\n    {\n        type: 'image',\n        url: 'https://randomuser.me/api/portraits/men/43.jpg',     // file path\n        position: 'center',                                  // position of image: 'left' | 'center' | 'right'\n        width: '160px',                                           // width of image in px; default: auto\n        height: '60px',                                          // width of image in px; default: 50 or '50px'\n    },{\n        type: 'text',                                       // 'text' | 'barCode' | 'qrCode' | 'image' | 'table\n        value: 'SAMPLE HEADING',\n        style: {fontWeight: \"700\", textAlign: 'center', fontSize: \"24px\"}\n    },{\n        type: 'text',                       // 'text' | 'barCode' | 'qrCode' | 'image' | 'table'\n        value: 'Secondary text',\n        style: {textDecoration: \"underline\", fontSize: \"10px\", textAlign: \"center\", color: \"red\"}\n    },{\n        type: 'barCode',\n        value: '023456789010',\n        height: 40,                     // height of barcode, applicable only to bar and QR codes\n        width: 2,                       // width of barcode, applicable only to bar and QR codes\n        displayValue: true,             // Display value below barcode\n        fontsize: 12,\n    },{\n        type: 'qrCode',\n        value: 'https://github.com/Hubertformin/electron-pos-printer',\n        height: 55,\n        width: 55,\n        style: { margin: '10 20px 20 20px' }\n    },{\n        type: 'table',\n        // style the table\n        style: {border: '1px solid #ddd'},\n        // list of the columns to be rendered in the table header\n        tableHeader: ['Animal', 'Age'],\n        // multi dimensional array depicting the rows and columns of the table body\n        tableBody: [\n            ['Cat', 2],\n            ['Dog', 4],\n            ['Horse', 12],\n            ['Pig', 4],\n        ],\n        // list of columns to be rendered in the table footer\n        tableFooter: ['Animal', 'Age'],\n        // custom style for the table header\n        tableHeaderStyle: { backgroundColor: '#000', color: 'white'},\n        // custom style for the table body\n        tableBodyStyle: {'border': '0.5px solid #ddd'},\n        // custom style for the table footer\n        tableFooterStyle: {backgroundColor: '#000', color: 'white'},\n    },{\n        type: 'table',\n        style: {border: '1px solid #ddd'},             // style the table\n        // list of the columns to be rendered in the table header\n        tableHeader: [{type: 'text', value: 'People'}, {type: 'image', path: path.join(__dirname, 'icons/animal.png')}],\n        // multi-dimensional array depicting the rows and columns of the table body\n        tableBody: [\n            [{type: 'text', value: 'Marcus'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/43.jpg'}],\n            [{type: 'text', value: 'Boris'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/41.jpg'}],\n            [{type: 'text', value: 'Andrew'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/23.jpg'}],\n            [{type: 'text', value: 'Tyresse'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/53.jpg'}],\n        ],\n        // list of columns to be rendered in the table footer\n        tableFooter: [{type: 'text', value: 'People'}, 'Image'],\n        // custom style for the table header\n        tableHeaderStyle: { backgroundColor: 'red', color: 'white'},\n        // custom style for the table body\n        tableBodyStyle: {'border': '0.5px solid #ddd'},\n        // custom style for the table footer\n        tableFooterStyle: {backgroundColor: '#000', color: 'white'},\n    },\n]\n\nPosPrinter.print(data, options)\n .then(console.log)\n .catch((error) =\u003e {\n    console.error(error);\n  });\n\n```\n\n## Typescript\n### Usage\n\n```typescript\nimport {PosPrinter, PosPrintData, PosPrintOptions} from \"electron-pos-printer\";\nimport * as path from \"path\";\n\nconst options: PosPrintOptions = {\n   preview: false,\n   margin: '0 0 0 0',    \n   copies: 1,\n   printerName: 'XP-80C',\n   timeOutPerLine: 400,\n   pageSize: '80mm' // page size\n}\n\nconst data: PosPrintData[] = [\n    {\n        type: 'image',\n        url: 'https://randomuser.me/api/portraits/men/43.jpg',     // file path\n        position: 'center',                                  // position of image: 'left' | 'center' | 'right'\n        width: '160px',                                           // width of image in px; default: auto\n        height: '60px',                                          // width of image in px; default: 50 or '50px'\n    },{\n        type: 'text',                                       // 'text' | 'barCode' | 'qrCode' | 'image' | 'table\n        value: 'SAMPLE HEADING',\n        style: {fontWeight: \"700\", textAlign: 'center', fontSize: \"24px\"}\n    },{\n        type: 'text',                       // 'text' | 'barCode' | 'qrCode' | 'image' | 'table'\n        value: 'Secondary text',\n        style: {textDecoration: \"underline\", fontSize: \"10px\", textAlign: \"center\", color: \"red\"}\n    },{\n        type: 'barCode',\n        value: '023456789010',\n        height: 40,                     // height of barcode, applicable only to bar and QR codes\n        width: 2,                       // width of barcode, applicable only to bar and QR codes\n        displayValue: true,             // Display value below barcode\n        fontsize: 12,\n    },{\n        type: 'qrCode',\n        value: 'https://github.com/Hubertformin/electron-pos-printer',\n        height: 55,\n        width: 55,\n        style: { margin: '10 20px 20 20px' }\n    },{\n        type: 'table',\n        // style the table\n        style: {border: '1px solid #ddd'},\n        // list of the columns to be rendered in the table header\n        tableHeader: ['Animal', 'Age'],\n        // multi dimensional array depicting the rows and columns of the table body\n        tableBody: [\n            ['Cat', 2],\n            ['Dog', 4],\n            ['Horse', 12],\n            ['Pig', 4],\n        ],\n        // list of columns to be rendered in the table footer\n        tableFooter: ['Animal', 'Age'],\n        // custom style for the table header\n        tableHeaderStyle: { backgroundColor: '#000', color: 'white'},\n        // custom style for the table body\n        tableBodyStyle: {'border': '0.5px solid #ddd'},\n        // custom style for the table footer\n        tableFooterStyle: {backgroundColor: '#000', color: 'white'},\n    },{\n        type: 'table',\n        style: {border: '1px solid #ddd'},             // style the table\n        // list of the columns to be rendered in the table header\n        tableHeader: [{type: 'text', value: 'People'}, {type: 'image', path: path.join(__dirname, 'icons/animal.png')}],\n        // multi-dimensional array depicting the rows and columns of the table body\n        tableBody: [\n            [{type: 'text', value: 'Marcus'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/43.jpg'}],\n            [{type: 'text', value: 'Boris'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/41.jpg'}],\n            [{type: 'text', value: 'Andrew'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/23.jpg'}],\n            [{type: 'text', value: 'Tyresse'}, {type: 'image', url: 'https://randomuser.me/api/portraits/men/53.jpg'}],\n        ],\n        // list of columns to be rendered in the table footer\n        tableFooter: [{type: 'text', value: 'People'}, 'Image'],\n        // custom style for the table header\n        tableHeaderStyle: { backgroundColor: 'red', color: 'white'},\n        // custom style for the table body\n        tableBodyStyle: {'border': '0.5px solid #ddd'},\n        // custom style for the table footer\n        tableFooterStyle: {backgroundColor: '#000', color: 'white'},\n    },\n]\n\nPosPrinter.print(data, options)\n .then(console.log)\n .catch((error) =\u003e {\n    console.error(error);\n  });\n```\n\n## Printing options\n| Options        | Required | Type                       | Description                                                                                                                                                                           |\n|----------------|:--------:|:---------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| printerName    |    No    | `string`                   | The printer's name. If not set, the system's default printer will be used.                                                                                                            | \n| copies         |    No    | `number`                   | The number of copies to print                                                                                                                                                         |\n| preview        |    No    | `boolean`                  | Preview print job in a window. Default is `false`                                                                                                                                     |\n| width          |    No    | `string`                   | Width of a page's content                                                                                                                                                             |\n| margin         |    No    | `string`                   | Margin of a page's content. CSS margin values can be used Ex. `0 10px`                                                                                                                | \n| timeOutPerLine |    No    | `number`                   | Timeout per line in milliseconds. Default value is 400                                                                                                                                | \n| silent         |    No    | `boolean`                  | To print silently without the system displaying the printer selection window. Default value is `true`                                                                                 | \n| pageSize       |    No    | `PaperSize`, `SizeOptions` | Configure the paper size which is supported by your printer. values are are  `80mm`, `78mm`, `76mm`, `58mm`, `57mm`, `44mm` or object with `width` and `height` properties in pixels. |                                                                                                                                                                                      |\n| pathTemplate   |    No    | `string`                   | Path to custom html template. Can be used for custom print styles.                                                                                                                    | \n| header         |    No    | `string`                   | Text to be printed as page header.                                                                                                                                                    | \n| footer         |    No    | `string`                   | Text to be printed as page footer.                                                                                                                                                    | \n| margins        |    No    | `object`                   | Page margins. [See electron docs](https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback)                                                              | \n| landscape      |    No    | `boolean`                  | Whether the page should be printed in landscape mode. Default is `false`.                                                                                                             | \n| scaleFactor    |    No    | `number`                   | The scale factor of the web page.                                                                                                                                                     | \n| pagesPerSheet  |    No    | `number`                   | The number of pages to print per page sheet.                                                                                                                                          | \n| collate        |    No    | `boolean`                  | Whether the page should be collated.                                                                                                                                                  | \n| pageRanges     |    No    | `object[]`                 | The page range to print. [See electron docs](https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback)                                                   | \n| duplexMode     |    No    | `string`                   | Set the duplex mode of the printed web page. [See electron docs](https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback)                               | \n| dpi            |    No    | `object`                   | [See electron docs](https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback)                                                                            |\n\n## The Print data object\n\u003e ### Important!!\n\u003e The `css` property is no longer supported, use the style property instead of css. \u003cbr /\u003e\n\u003e Example: `style: {fontWeight: \"700\", textAlign: 'center', fontSize: \"24px\"}`\n\n| Property         | Type                                     | Description                                                                               |\n|------------------|------------------------------------------|:------------------------------------------------------------------------------------------|\n| type             | `string`                                 | `text`, `qrCode`, `barCode`, `image`, `table` // type `text` can be an html string        |\n| value            | `string`                                 | Value of the current row                                                                  |\n| height           | `number`                                 | Applicable to type barCode and qrCode                                                     |\n| width            | `number`                                 | Applicable to type barCode and qrCode                                                     |\n| style            | `PrintDataStyle`                         | Add css styles to line (jsx syntax) \u003cbr /\u003eex: `{fontSize: 12, backgroundColor: '#2196f3}` |\n| displayValue     | `boolean`                                | Display value of barcode below barcode                                                    |\n| position         | `string`                                 | `left`, `center`, `right` applicable to types qrCode and image                            |\n| path             | `string`                                 | Path or url to the image asset                                                            |\n| url              | `string`                                 | Url to image or a base 64 encoding of image                                               |\n| tableHeader      | `PosPrintTableField[]` or `string[]`     | The columns to be rendered in the header of the table. Works with type `table`            |\n| tableBody        | `PosPrintTableField[][]` or `string[][]` | The columns to be rendered in the body of the table. Works with type `table`              |\n| tableFooter      | `PosPrintTableField[]` or `string[]`     | The columns to rendered it the footer of the table. Works with type `table`               |\n| tableHeaderStyle | `string`                                 | Set a custom style to the table header                                                    |\n| tableBodyStyle   | `string`                                 | Set a custom style to the table body                                                      |\n| tableFooterStyle | `string`                                 | Set a custom style to the table footer                                                    |\n\n## Contributors\nThanks to our [contributors](https://github.com/Hubertformin/electron-pos-printer/graphs/contributors) 🎉👏\n- [Hubert Formin](https://github.com/Hubertformin)\n- [Sidnei Pacheco](https://github.com/sidneip)\n- [Ulisses Constantini](https://github.com/ulissesc)\n- [Famous Ketoma](https://github.com/jfamousket)","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubertformin%2Felectron-pos-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHubertformin%2Felectron-pos-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHubertformin%2Felectron-pos-printer/lists"}