Created
December 5, 2018 17:41
-
-
Save lite1979/30cb2c6d5ea50fd8a59a6effe837e882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function printESCP() { | |
var config = qz.configs.create("Epson-TM-BA-Thermal"); | |
var data = [{ | |
type: 'html', | |
format: 'plain', // or 'plain' if the data is raw HTML | |
data: ' <html><header><title>This is the title</title></header><body>Hello world</body></html>' | |
}]; | |
qz.print(config, data) | |
.then(function() { | |
var config = qz.configs.create("Epson-TM-BA-Thermal"); | |
var data = [{ | |
type: 'image', | |
data: 'assets/img/image_sample.png' | |
}]; | |
return qz.print(config, data); | |
}) | |
.then(function() { | |
var config = qz.configs.create("Epson-TM-BA-Thermal",{altPrinting:true}); | |
var printData = [ | |
'\x1B' + '\x40', // init | |
'\x1B' + '\x61' + '\x31', // center align | |
'Canastota, NY 13032' + '\x0A', | |
'\x0A', // line break | |
'www.qzindustries.com' + '\x0A', // text and line break | |
'\x0A', // line break | |
'\x0A', // line break | |
'November 21, 2015 3:09 PM' + '\x0A', | |
'\x0A', // line break | |
'\x0A', // line break | |
'\x0A', | |
'Transaction # 123456 Register: 3' + '\x0A', | |
'\x0A', | |
'\x0A', | |
'\x0A', | |
'\x1B' + '\x61' + '\x30', // left align | |
'Baklava (Qty 4) 9.00' + '\x1B' + '\x74' + '\x13' + '\xAA', //print special character symbol after numeric value | |
'\x0A', | |
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' + '\x0A', | |
'\x1B' + '\x45' + '\x0D', // bold on | |
'Here\'s some bold text!', | |
'\x1B' + '\x45' + '\x0A', // bold off | |
'\x0A' + '\x0A', | |
'\x1B' + '\x61' + '\x32', // right align | |
'\x1B' + '\x21' + '\x30', // em mode on | |
'DRINK ME', | |
'\x1B' + '\x21' + '\x0A' + '\x1B' + '\x45' + '\x0A', // em mode off | |
'\x0A' + '\x0A', | |
'\x1B' + '\x61' + '\x30', // left align | |
'------------------------------------------' + '\x0A', | |
'\x1B' + '\x4D' + '\x31', // small text | |
'EAT ME' + '\x0A', | |
'\x1B' + '\x4D' + '\x30', // normal text | |
'------------------------------------------' + '\x0A', | |
'normal text', | |
'\x1B' + '\x61' + '\x30', // left align | |
'\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A', | |
'\x1B' + '\x69', // cut paper | |
]; | |
return qz.print(config, printData); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment