Open InesBorgesCore opened 2 years ago
I have tried printing QRCodes with the demo app and it also prints two in a row. Why? Is it because of the printer?
Hello, i have the same error, the QR image print two images in second line. See the picture: https://ibb.co/Kynk5bd
Hello, i have the same error, the QR image print two images in second line. See the picture: https://ibb.co/Kynk5bd
In my case, fixed when comment the line of relationed with: Print the symbol data in the symbol storage area, these provoques to print double
Hello, i have the same error, the QR image print two images in second line. See the picture: https://ibb.co/Kynk5bd
In my case, fixed when comment the line of relationed with: Print the symbol data in the symbol storage area, these provoques to print double
This also worked for me, a pull request should be created
Hello, I am facing the following problems:
I tried printing a timestamp with printBarcode in a EAN13 format but when I scanned the barcode there was always one number switched so the barcode was never the corresponding one that corresponded with the text bellow it.
So to solve this problem I switched to printQRCode and printed a QRCode with the timestamp. However the first time worked perfectly fine but the next ones always printed two QRCodes in a row. The first was the previous timestamp and the second was the new timestamp. How can I print only the new timestamp?
Here is a piece of my code:
function imprimirNaImpressoraBolso(timestamp: string){ var printerName: any; BTPrinter.list(function(data1: any){ console.log("Success list"); console.log("Devices list: ", data1); // paired bluetooth devices array printerName = data1[0]; BTPrinter.status(function(data: any){ console.log("Success status"); console.log("Device status: " + data) // bt status: true or false BTPrinter.connect(function(data: any){ console.log("Success connect"); console.log("connect: " + data); console.warn("Printer name: " + printerName); // BTPrinter.printBarcode(function(data: any){ // console.log("Success print barcode"); // console.log(data); // BTPrinter.disconnect(function(data: any){ // console.log("Success disconnect"); // console.log(data) // },function(err: any){ // console.log("Error disconnect"); // console.log(err) // }, printerName); // },function(err: any){ // console.log("Error print barcode"); // console.log(err); // }, system, timestamp, align, position, font, height); BTPrinter.printQRCode(function(data: any){ console.log("Success print qrcode"); console.log(data); BTPrinter.disconnect(function(data: any){ console.log("Success disconnect"); console.log(data) },function(err: any){ console.log("Error disconnect"); console.log(err) }, printerName); },function(err: any){ console.log("Error print qrcode"); console.log(err); }, timestamp, align, model, size, eclevel); },function(err: any){ console.log("Error connect"); console.log(err) console.warn("Printer name: " + printerName); }, printerName); },function(err: any){ console.log("Error status"); console.log(err) }); },function(err: any){ console.log("Error list"); console.log(err); }); }
This function prints a QRCode, actually it prints two in a row. Why? Thank you in advance
Hi Ines! are you using this resource in ionic project? I'm trying to use this same resource to print but in my Ionic project is not working, i receive this message when i try to print something using QRcode:
this is my code:
import { BluetoothSerial } from '@ionic-native/bluetooth-serial/ngx'; import { Platform } from '@ionic/angular'; import { Diagnostic } from '@ionic-native/diagnostic/ngx'; declare let BTPrinter: any;
IN MY LIST EVERYTHING IS WORKING I CAN FIND THE PRINTER: async scan_printers() { const list = [] this.gettingDevices = true; this.unpairedDevices = null; BTPrinter.list((data) => { console.log("Success"); console.log(data); //list of printer in data array while(data.length > 0) { const [name, address] = data.splice(0, 3) list.push({ name, address }) } this.unpairedDevices = list; this.gettingDevices = false; },function(err){ console.log("Error"); console.log(err); })
BUT HERE WHEN I TRY TO PRINT MY QRCODE, NO WAY: print_QRcode() {
var align = 1;
var model = 49;
var size = 32;
var eclevel = 50;
BTPrinter.printQRCode(function(data){
console.log("Success");
console.log(data);
},function(err){
console.log("Error");
console.log(err);
}, data, align, model, size, eclevel);
}
this is the error: vendor.js:49767 ERROR Error: Uncaught (in promise): TypeError: callback.fail.apply is not a function TypeError: callback.fail.apply is not a function any suggestion? thanks!
using your code i don't have any errors, but nothing happens.
what values are you using here: var align = ? var model = ? var size = ? var eclevel = ?
Hello, I am facing the following problems:
I tried printing a timestamp with printBarcode in a EAN13 format but when I scanned the barcode there was always one number switched so the barcode was never the corresponding one that corresponded with the text bellow it.
So to solve this problem I switched to printQRCode and printed a QRCode with the timestamp. However the first time worked perfectly fine but the next ones always printed two QRCodes in a row. The first was the previous timestamp and the second was the new timestamp. How can I print only the new timestamp?
Here is a piece of my code:
function imprimirNaImpressoraBolso(timestamp: string){ var printerName: any; BTPrinter.list(function(data1: any){ console.log("Success list"); console.log("Devices list: ", data1); // paired bluetooth devices array printerName = data1[0]; BTPrinter.status(function(data: any){ console.log("Success status"); console.log("Device status: " + data) // bt status: true or false BTPrinter.connect(function(data: any){ console.log("Success connect"); console.log("connect: " + data); console.warn("Printer name: " + printerName); // BTPrinter.printBarcode(function(data: any){ // console.log("Success print barcode"); // console.log(data); // BTPrinter.disconnect(function(data: any){ // console.log("Success disconnect"); // console.log(data) // },function(err: any){ // console.log("Error disconnect"); // console.log(err) // }, printerName); // },function(err: any){ // console.log("Error print barcode"); // console.log(err); // }, system, timestamp, align, position, font, height); BTPrinter.printQRCode(function(data: any){ console.log("Success print qrcode"); console.log(data); BTPrinter.disconnect(function(data: any){ console.log("Success disconnect"); console.log(data) },function(err: any){ console.log("Error disconnect"); console.log(err) }, printerName); },function(err: any){ console.log("Error print qrcode"); console.log(err); }, timestamp, align, model, size, eclevel); },function(err: any){ console.log("Error connect"); console.log(err) console.warn("Printer name: " + printerName); }, printerName); },function(err: any){ console.log("Error status"); console.log(err) }); },function(err: any){ console.log("Error list"); console.log(err); }); }
This function prints a QRCode, actually it prints two in a row. Why? Thank you in advance
using your code i don't have any errors, but nothing happens.
what values are you using here?: var align = ? var model = ? var size = ? var eclevel = ?
Instead I used the following code:
function imprimirNaImpressoraBolso(timestamp: string){
var printerName: any;
BTPrinter.list(function(data1: any){
console.log("Success list");
console.log("Devices list: ", data1); // paired bluetooth devices array
printerName = data1[0];
BTPrinter.status(function(data: any){
console.log("Success status");
console.log("Device status: " + data) // bt status: true or false
BTPrinter.connect(function(data: any){
console.log("Success connect");
console.log("connect: " + data);
console.warn("Printer name: " + printerName);
let base64String = textToBase64Barcode(timestamp);
console.log(base64String);
BTPrinter.printBase64(function(data: any){
console.log("Success base 64 print");
console.log(data);
setTimeout(() => {
BTPrinter.disconnect(function(data: any){
console.log("Success disconnect");
console.log(data)
},function(err: any){
console.log("Error disconnect");
console.log(err)
}, printerName);
}, 3000);
},function(err: any){
console.error("Error base 64 print");
console.log(err);
}, base64String,'1');//base64 string, align
},function(err: any){
console.log("Error connect");
console.log(err)
console.warn("Printer name: " + printerName);
}, printerName);
},function(err: any){
console.log("Error status");
console.log(err)
});
},function(err: any){
console.log("Error list");
console.log(err);
});
The difference is that I use barcodes and I use setTimeout. I didn't try it but maybe the use of a setTimeout will prevent the qrcode to be printed two times in a row. Try it. You have to use setTimeout. Is on the documentation. @ademir10
Instead I used the following code:
function imprimirNaImpressoraBolso(timestamp: string){ var printerName: any; BTPrinter.list(function(data1: any){ console.log("Success list"); console.log("Devices list: ", data1); // paired bluetooth devices array printerName = data1[0]; BTPrinter.status(function(data: any){ console.log("Success status"); console.log("Device status: " + data) // bt status: true or false BTPrinter.connect(function(data: any){ console.log("Success connect"); console.log("connect: " + data); console.warn("Printer name: " + printerName); let base64String = textToBase64Barcode(timestamp); console.log(base64String); BTPrinter.printBase64(function(data: any){ console.log("Success base 64 print"); console.log(data); setTimeout(() => { BTPrinter.disconnect(function(data: any){ console.log("Success disconnect"); console.log(data) },function(err: any){ console.log("Error disconnect"); console.log(err) }, printerName); }, 3000); },function(err: any){ console.error("Error base 64 print"); console.log(err); }, base64String,'1');//base64 string, align },function(err: any){ console.log("Error connect"); console.log(err) console.warn("Printer name: " + printerName); }, printerName); },function(err: any){ console.log("Error status"); console.log(err) }); },function(err: any){ console.log("Error list"); console.log(err); });
The difference is that I use barcodes and I use setTimeout. I didn't try it but maybe the use of a setTimeout will prevent the qrcode to be printed two times in a row. Try it. You have to use setTimeout. Is on the documentation. @ademir10
thank you so much! when i try to use your code i have something missing, could you tell me where i find this guy? textToBase64Barcode I tried to find it on documentation but there is nothing talking about it.
look at my print, thanks!
@ademir10 That is a custom function
function textToBase64Barcode(text: string){
var canvas = document.createElement("canvas");
JsBarcode(canvas, text, {width: 3, height: 100, marginBottom: 200});
return canvas.toDataURL("image/png");
}
JSBarcode is a script that prepares a barcode.
You can get it from this script tag:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsbarcode/3.11.3/JsBarcode.all.min.js"></script>
Hello, I am facing the following problems:
I tried printing a timestamp with printBarcode in a EAN13 format but when I scanned the barcode there was always one number switched so the barcode was never the corresponding one that corresponded with the text bellow it.
So to solve this problem I switched to printQRCode and printed a QRCode with the timestamp. However the first time worked perfectly fine but the next ones always printed two QRCodes in a row. The first was the previous timestamp and the second was the new timestamp. How can I print only the new timestamp?
Here is a piece of my code:
This function prints a QRCode, actually it prints two in a row. Why? Thank you in advance