{"id":14986787,"url":"https://github.com/ingoncalves/escpos-xml","last_synced_at":"2025-04-11T23:01:57.428Z","repository":{"id":53589227,"uuid":"103964587","full_name":"ingoncalves/escpos-xml","owner":"ingoncalves","description":"JavaScript library that implements the thermal printer ESC / POS protocol and provides an XML interface for preparing templates for printing.","archived":false,"fork":false,"pushed_at":"2021-03-22T20:46:47.000Z","size":340,"stargazers_count":48,"open_issues_count":14,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-04T11:13:48.799Z","etag":null,"topics":["escpos","handlebars","json","momentjs","numeraljs","printer","template","xml"],"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/ingoncalves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-18T16:34:26.000Z","updated_at":"2024-09-05T13:24:29.000Z","dependencies_parsed_at":"2022-09-12T16:52:31.460Z","dependency_job_id":null,"html_url":"https://github.com/ingoncalves/escpos-xml","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingoncalves%2Fescpos-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingoncalves%2Fescpos-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingoncalves%2Fescpos-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingoncalves%2Fescpos-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ingoncalves","download_url":"https://codeload.github.com/ingoncalves/escpos-xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239805823,"owners_count":19700192,"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":["escpos","handlebars","json","momentjs","numeraljs","printer","template","xml"],"created_at":"2024-09-24T14:13:33.127Z","updated_at":"2025-02-20T08:31:33.871Z","avatar_url":"https://github.com/ingoncalves.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESC/POS XML\n\nJavaScript library that implements the thermal printer ESC / POS protocol and provides an XML interface for preparing templates for printing.\n\n**Features:**\n- [x] Text\n- [x] Text line\n- [x] Feed line\n- [x] Bold text\n- [x] Underline text\n- [x] Font size\n- [x] Small mode\n- [x] White mode\n- [x] Align\n- [x] Barcode\n- [x] QRcode\n- [x] Paper cut node\n- [ ]  Image\n- [x] XML with Handlebars\n- [x] Handlebars [Moment](http://momentjs.com) Helper\n- [x] Handlebars [Numeral](http://numeraljs.com) Helper\n\n## Installation\n\nUsing npm:\n\n```\nnpm install --save escpos-xml\n```\n\n## Usage\n\nIn JavaScript:\n\n### From plain XML\n```js\n\nimport { EscPos } from 'escpos-xml';\n\nconst xml = `\n  \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n  \u003cdocument\u003e\n    \u003ctext-line\u003ehello world\u003c/text-line\u003e\n  \u003c/document\u003e\n`;\n\nconst buffer = EscPos.getBufferXML(xml);\n// send this buffer to a stream (eg.: bluetooth)\n\n```\n\n### From XML + Handlebars\n```js\n\nimport { EscPos } from 'escpos-xml';\n\nconst xml = `\n  \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n  \u003cdocument\u003e\n    \u003ctext-line\u003e{{foo}}\u003c/text-line\u003e\n  \u003c/document\u003e\n`;\n\nconst data = {\n  foo: 'hello word'\n};\n\nconst buffer = EscPos.getBufferFromTemplate(xml, data);\n// send this buffer to a stream (eg.: bluetooth)\n\n```\n\n### From Builder\n```js\n\nimport { EscPos } from 'escpos-xml';\n\n\nconst buffer = EscPos.getBufferBuilder()\n                             .printTextLine('hello world')\n                             .build();\n// send this buffer to a stream (eg.: bluetooth)\n\n```\n\n## API\n\nComming soon...\nFor a while, this example may help you:\n\n```js\nimport { EscPos } from 'escpos-xml';\n\nconst xml = `\n  \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n  \u003cdocument\u003e\n      \u003cline-feed /\u003e\n      \u003calign mode=\"center\"\u003e\n          \u003cbold\u003e\n              \u003ctext-line size=\"1:1\"\u003e{{title}}\u003c/text-line\u003e\n          \u003c/bold\u003e\n          \u003cline-feed /\u003e\n          \u003csmall\u003e\n              \u003ctext-line\u003e{{subtitle}}\u003c/text-line\u003e\n          \u003c/small\u003e\n      \u003c/align\u003e\n      \u003csmall\u003e\n          \u003ctext-line\u003eDate: {{moment date format=\"DD/MM/YYYY HH:mm:ss\"}}\u003c/text-line\u003e\n          \u003ctext-line size=\"1:0\"\u003e{{numeral price format=\"$ 0,0.00\"}}\u003c/text-line\u003e\n          \u003ctext-line size=\"1:0\"\u003e{{paddedString}}\u003c/text-line\u003e\n      \u003c/small\u003e\n      \u003cline-feed /\u003e\n      \u003cunderline\u003e\n        \u003ctext-line\u003e{{underline}}\u003c/text-line\u003e\n      \u003c/underline\u003e\n      \u003cline-feed /\u003e\n      \u003calign mode=\"center\"\u003e\n          \u003cwhite-mode\u003e\n              \u003ctext-line size=\"1:1\"\u003e{{description}}\u003c/text-line\u003e\n          \u003c/white-mode\u003e\n          \u003cline-feed /\u003e\n          \u003cbold\u003e\n              {{#if condictionA}}\n              \u003ctext-line size=\"1:0\"\u003eTrue A\u003c/text-line\u003e\n              {{else if condictionB}}\n              \u003ctext-line size=\"1:0\"\u003eTrue B\u003c/text-line\u003e\n              {{else}}\n              \u003ctext-line size=\"1:0\"\u003eFalse\u003c/text-line\u003e\n              {{/if}}\n          \u003c/bold\u003e\n      \u003c/align\u003e\n      \u003cline-feed /\u003e\n      \u003calign mode=\"center\"\u003e\n          \u003cbarcode system=\"CODE_128\" width=\"DOT_250\"\u003e{{barcode}}\u003c/barcode\u003e\n      \u003c/align\u003e\n      \u003cline-feed /\u003e\n      \u003calign mode=\"center\"\u003e\n          \u003cqrcode ecl=\"M\"\u003e{{qrcode}}\u003c/qrcode\u003e\n      \u003c/align\u003e\n    \u003cpaper-cut/\u003e\n  \u003c/document\u003e\n`;\n\nconst data = {\n  title: 'Tile',\n  subtitle: 'Subtitle',\n  description: 'This is a description',\n  date: new Date(),\n  price: 1.99,\n  paddedString: '\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Line padded with 4 spaces',\n  condictionA: false,\n  condictionB: true,\n  barcode: '12345678',\n  qrcode: 'hello qrcode',\n  underline: 'underline'\n}\n\nconst buffer = EscPos.getBufferFromTemplate(xml, data);\n// send this buffer to a stream (eg.: bluetooth)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fingoncalves%2Fescpos-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fingoncalves%2Fescpos-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fingoncalves%2Fescpos-xml/lists"}