ansontio / esc-pos-encoder-ionic-demo Goto Github PK
View Code? Open in Web Editor NEWAn Ionic 5 demo application to print a thermal receipt through bytcode.
License: MIT License
An Ionic 5 demo application to print a thermal receipt through bytcode.
License: MIT License
when print Arabic display ?????????
ReferenceError: Socket is not defined
Hi, I try to use "esc-pos-encoder-ionic" NPM package in my Ionic project.
When I try to open the page which use the service contains the imported library I have this error:
ERROR Error: Uncaught (in promise): ReferenceError: Cannot access 'HomePageModule' before initialization
ReferenceError: Cannot access 'HomePageModule' before initialization
Related code:
import EscPosEncoder from 'esc-pos-encoder-ionic';
//----
createTicket(){
const encoder = new EscPosEncoder();
const result = encoder.initialize();
result
.align('center')
.newline()
.line('Congratulation, print success')
.line('IP : ' + '192.168.1.1')
.line('Port : ' + '9100')
.newline()
.newline()
.newline()
.newline()
.newline()
.newline()
.cut();
const resultByte = result.encode();
// send byte code into the printer
socket.open(
'192.168.1.1',
'9100',
() => {
socket.write(resultByte, () => {
socket.shutdownWrite();
});
},
(err) => {
console.error(err);
}
);
}
hi
may i know is there a "Beeper" Sound function?
i found some resource for the command for those who need can find from below link :
https://github.com/stefanosbou/esc-pos-java/blob/master/src/main/java/io/github/escposjava/print/Commands.java
https://github.com/escpos/escpos/blob/master/lib/escpos.rb
For those who want to add into the plugin can add below code into esc-pos-encoder.js
beeper() {
this._queue([
0x1b,0x42,0x05,0x01
]);
return this;
}
cashdrawer() {
this._queue([
0x1b,0x70,0x00
]);
return this;
}
Question posted on stackoverflow moved into issue ticket.
Need more information about the issue from @glen
Hello everyone.
I have been trying to print a receipt using this package to send the data to the printer, however when I try to print with an image it is not working properly, the printer stops at a certain point and does not keep printing. This is my code:
var impresora = this.printerService;
const encoder = new EscPosEncoder();
let img = new Image();
img.src = 'assets/imgs/colsaisa3.png';
img.onload = function () {
const encoder = new EscPosEncoder();
let result = encoder
.codepage('cp852')
// .newline()
.image(img, 120, 120, 'atkinson')
.newline()
.newline()
.align('center')
.line('Recibo de caja')
.line(resp.id)
.newline()
.newline()
.align('left')
.line('CLIENTE: ' + resp.cliente)
.line('IDEN: ' + resp.iden)
.line('FECHA: ' + resp.fecha)
.line('VENDEDOR: ' + resp.vendedor)
.newline()
.newline()
.bold(true)
.line('FACTURA SALDO PAGO')
.bold(false);
for (const item of resp.facturas) {
const cantFactura = (item.numeroFactura.toString().length <= 11) ? 11 - item.numeroFactura.toString().length : 0;
const cantSaldo = (formatNumber(item.saldo, 'en-US').length <= 11) ? 11 - formatNumber(item.saldo, 'en-US').length : 0;
const cantPago = (formatNumber(item.valorConsignar, 'en-US').length <= 11) ? 11 - formatNumber(item.valorConsignar, 'en-US').length : 0;
const line = item.numeroFactura + ' '.repeat(cantFactura) + ' $' + formatNumber(item.saldo, 'en-US') + ' '.repeat(cantSaldo) + ' $' + formatNumber(item.valorConsignar, 'en-US') + ' '.repeat(cantPago);
// console.log({cantFactura, cantSaldo, cantPago, line});
result = result.line(line);
}
result = result
.line('-------------------------------')
.line('TOTAL PAGADO ' + resp.totalPagado)
.newline()
.newline()
.line('Formas Pago')
.line('-------------------------------');
for (const item of resp.formasPago) {
result = result.line(item.tipo + ' $' + item.valor);
}
result = result
.line('-------------------------------')
.line('TOTAL PAGADO ' + resp.totalPagado)
.newline()
.line('Estimado cliente.')
.line('Su pago lo podrá ver reflejado')
.line('en el portal de clientes')
.line('www.tiendacolsaisa.com')
.line('en las próximas 48 horas.')
.newline()
.line('Recuerde que los descuentos por')
.line('pronto pago sólo son')
.line('aplicados si usted se encuentra')
.line('al día en cartera.')
.newline()
.bold(true)
.line('Gracias por preferir a COLSAISA.')
.bold(false)
.newline()
.newline()
.encode();
// console.log({ result });
impresora.imprimirEnImpresoraBluetooth(item.id, result);
The funny thing about all this is that if I comment on the line where I use the image, the receipt prints completely.
I attach some videos where you can see the behavior. The first is when the image is used and the second is when I comment the line where the image is used:
Can anyone give me an idea why you may be presenting this and how to fix it?
Thank you very much for your help.
Hi, I use this plugin and it show -[NSTaggedPointerString stringValue]: unrecognized selector sent to instance 0x8b216251c40245f7 error when I sent data to TCP/IP
any idea hot to fix it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.