Skip to content

Commit 57202e3

Browse files
authored
Merge pull request #6 from captainjapeng/master
Fix #5 - Added support for whitespaces.
2 parents 8ff6546 + 16c2f0f commit 57202e3

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ const xml = `
106106
<small>
107107
<text-line>Date: {{moment date format="DD/MM/YYYY HH:mm:ss"}}</text-line>
108108
<text-line size="1:0">{{numeral price format="$ 0,0.00"}}</text-line>
109+
<text-line size="1:0">{{paddedString}}</text-line>
109110
</small>
110111
<line-feed />
111112
<underline>
@@ -144,6 +145,7 @@ const data = {
144145
description: 'This is a description',
145146
date: new Date(),
146147
price: 1.99,
148+
paddedString: '&nbsp;&nbsp;&nbsp;&nbsp;Line padded with 4 spaces',
147149
condictionA: false,
148150
condictionB: true,
149151
barcode: '12345678',
@@ -155,4 +157,3 @@ const buffer = EscPos.getBufferFromTemplate(xml, data);
155157
// send this buffer to a stream (eg.: bluetooth)
156158

157159
```
158-

index.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/nodes/text-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class TextNode extends XMLNode {
1414
bufferBuilder.setCharacterSize(size[0], size[1]);
1515
}
1616

17-
let text = this.getContent();
17+
let text = this.getContent().replace(/&nbsp;/g, ' ');
1818
bufferBuilder.printText(text);
1919
return bufferBuilder;
2020
}

0 commit comments

Comments
 (0)