Open shareefmorayur opened 6 years ago
Change to the below code, it will work.
let width = 200; //width of the above image let height = 229; // height of the above image sunmiInnerPrinter.printBitmap('yourbase64imagedata', width, height);
Did you solve it? I had the same issue
Hi there!!, Bitmap refers to a .bmp file, so a png or other type image would not work. Other thing to consider is that the base64Data goes with out the "data:image/png;base64," part. Adjusting both things it will work
thank you @mmunozha it's work (y)
I have a problem with bitmap printing, when I start my application and make the first impression, it does not print what was requested. On the second print attempt, it prints what was sent on the first try. Follow my code below:
let realizaImpressao = (arquivo, nome = '') => {
try {
var image = new Image()
image.src = 'data:image/png;base64,' + arquivo
image = document.body.appendChild(image)
image.onload = function () {
$(function () {
window.sunmiInnerPrinter.printBitmap(arquivo, 384, image.height)
})
image.remove()
}
} catch (e) {
throw e
}
}
export default {
realizaImpressao
}
Thank you in advance.
Having same problem here.
My function is:
print() {
var element = document.getElementById('square');
html2canvas(element, { allowTaint : true }).then((canvas) =>
{
canvas.getContext('2d');
var image = canvas.toDataURL('image/jpeg', 1.0);
console.log(image);
sunmiInnerPrinter.printOriginalText("Test");
sunmiInnerPrinter.printBitmap(image, image.width, image.height);
});
Someone knows how can I solve this?
Change to the below code, it will work.
let width = 200; //width of the above image let height = 229; // height of the above image sunmiInnerPrinter.printBitmap('yourbase64imagedata', width, height);
I tried that, but also did not work
print() {
var element = document.getElementById('square');
html2canvas(element, { allowTaint : true }).then((canvas) =>
{
canvas.getContext('2d');
var image = canvas.toDataURL('image/jpeg', 1.0);
console.log(image);
sunmiInnerPrinter.printOriginalText("TEST\n");
let width = 100;
let height = 100;
sunmiInnerPrinter.printBitmap(image, width, height);
});
The function printOriginalText works fine.
Hi @pailoro try to remove 'data:image/jpg;base64,' from variable image.
var base64result = image.split(',')[1];
sunmiInnerPrinter.printBitmap(base64result, width, height);
Hi @zoldek
IT WORKS!
Thank you!!!!
hi, Wich one should i use to print webview content ? printBitmap OR printOriginalText OR printText ? Thanks :)
@iThamer First you need to convert the DOM to image and then use printBitmap. You can use html2canvas to convert the markup to image.
like that:
print() {
var element = document.getElementById('id_name');
html2canvas(element, { allowTaint : true }).then((canvas) =>
{
canvas.getContext('2d');
var image = canvas.toDataURL('image/jpeg', 1.0);
var base64result = image.split(',')[1];
console.log(image);
let width = 600;
let height = 613;
sunmiInnerPrinter.printBitmap(base64result, width, height);
});
it works 👍
Thank you :)
BTPrinter.printPOSCommand(function (data) { console.log("Success pos"); console.log(data) }, function (err) { console.log("Error pos"); console.log(err) }, "0x10 0x14 0x00 0x00 0x00")
Not working, any body can help how to run cash drawer command
Thank you labib for a great plugin.
I tried the app to print with sunmi inner printer, Text printing is worked properly. But the printBitmap is not working and printed nothing. There is no any action after function call. What is the reason for that?? What is the purpose of width and height in printBitmap arguments ( I just given the image width and height for testing) ?? My Code is given below
Please advice me.
Thank you in advance