Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- testImage(){
- this.platform.ready().then(()=>{
- preparaBase64('path image');
- function preparaBase64(url) {
- readImage(url, function (base64) {
- print(base64);
- });
- }
- function readImage(url, callback) {
- console.log(url);
- var request = new XMLHttpRequest();
- request.onload = function () {
- var file = new FileReader();
- file.onloadend = function () {
- callback(file.result);
- }
- file.readAsDataURL(request.response);
- };
- request.open('GET', url);
- request.responseType = 'blob';
- request.send();
- }
- function print(base64) {
- window.BTPrinter.list(function (data1) {
- window.BTPrinter.connect(function (data2) {
- console.log(data2);
- window.BTPrinter.printBase64(function (data) {
- console.log(data);
- }, function (err) {
- console.log(err);
- }, base64, '1');
- window.BTPrinter.printPOSCommand(null, null, "0A");
- window.BTPrinter.printPOSCommand(null, null, "0A");
- window.BTPrinter.printPOSCommand(null, null, "0A");
- window.BTPrinter.printPOSCommand(null, null, "0A");
- }, function (err) {
- console.log(err);
- }, "print name");
- }, function (err) {
- console.log(err);
- });
- window.BTPrinter.disconnect(function (data) {
- console.log(data);
- }, function (err) {
- console.log(err);
- }, "print name");
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement