Skip to content

Commit c95059e

Browse files
committed
Don't trim tickets line breaks
1 parent b437536 commit c95059e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ The app now runs standalone via Electron.
2828
## References
2929
* [ZPL Command Support](http://labelary.com/docs.html)
3030
* [ZPL Web Service](http://labelary.com/service.html)
31+
* [Esc/Pos Commands](https://escpos.readthedocs.io/en/latest/commands.html)
32+
* [Esc/Pos receipt print tools](https://github.com/receipt-print-hq/escpos-tools)
3133
* [Electron](https://www.electronjs.org)
3234
* [Electron Forge](https://www.electronforge.io)
33-
* [Esc/Pos receipt print tools](https://github.com/receipt-print-hq/escpos-tools)
3435

3536
## Release notes
3637

ZplEscPrinter/js/main.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function notify(text, glyphicon, type, delay) {
110110
setTimeout(function () { el.fadeOut(1000); }, delay || 2000);
111111
}
112112
async function zpl(data){
113-
try{ data = atob(data).trim(); }catch(e){}
113+
try{ data = atob(data.trim()); }catch(e){}
114114
const zpls = data.split(/\^XZ|\^xz/);
115115
const factor = configs.unit === '1' ? 1 : (configs.unit === '2' ? 2.54 : (configs.unit === '3' ? 25.4 : 96.5));
116116
const width = parseFloat(configs.width) / factor;
@@ -150,7 +150,7 @@ async function zpl(data){
150150
}
151151
}
152152
async function escpos(data){
153-
try{ data = atob(data).trim(); }catch(e){}
153+
try{ data = atob(data.trim()); }catch(e){}
154154
try{ data = JSON.parse(JSON.stringify(data).replaceAll(/(\\\\|\/)[u|U]00/g, '\\u00').replaceAll(/\\\\[x|X]/g, '\\x')); }catch(e){}
155155

156156
if (!data || !data.trim().length) {
@@ -251,7 +251,7 @@ function startTcpServer() {
251251
notify('{0} bytes received from Client: <b>{1}</b> Port: <b>{2}</b>'.format(data.length, clientSocketInfo.peerAddress, clientSocketInfo.peerPort), 'print', 'info', 1000);
252252

253253
const regex = /POST.*\r\n\r\n/gs;
254-
const code = String.fromCharCode.apply(null, new Uint8Array(data)).replace(regex,'').trim();
254+
const code = String.fromCharCode.apply(null, new Uint8Array(data)).replace(regex,'');
255255
if (code.includes('Host:') && code.includes('Connection: keep-alive') && code.includes('HTTP')) {
256256
console.log('It\'s an ajax call');
257257
return;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zpl-escpos-printer",
33
"productName": "Zpl/EscPos Printer",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"description": "Printer emulator for Zpl/EscPos rendering engine.",
66
"main": "main.js",
77
"scripts": {

0 commit comments

Comments
 (0)