Last active
November 10, 2022 02:52
-
-
Save parzibyte/2a5fa13116e85c600ccc1bc3cc37ca5c to your computer and use it in GitHub Desktop.
Print QR on a thermal printer by using JavaScript client side - https://parzibyte.me/blog/2022/09/30/plugin-impresoras-termicas-version-3/
This file contains 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
const imprimirQr = async (nombreImpresora) => { | |
const contenido = $qr.value; | |
if (!contenido) { | |
return alert("Escribe el contenido del QR"); | |
} | |
const conector = new ConectorPluginV3(URLPlugin); | |
conector.Iniciar(); | |
conector.ImprimirCodigoQr(contenido, 160, 2, ConectorPluginV3.TAMAÑO_IMAGEN_NORMAL); | |
conector.Iniciar(); //Nota: esto solo es necesario en ocasiones, por ejemplo en mi impresora debo hacerlo siempre que acabo de imprimir una imagen | |
conector.Feed(1); | |
const respuesta = await conector | |
.imprimirEn(nombreImpresora); | |
if (respuesta === true) { | |
alert("Impreso correctamente"); | |
} else { | |
alert("Error: " + respuesta); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment