Open rizwanbao opened 2 years ago
Can you give us the code which you're using? Because its a bit hard to find out what it could be.
Samples: https://github.com/paystory-de/thermal-printer-cordova-plugin/issues/15#issuecomment-1128100770 https://github.com/paystory-de/thermal-printer-cordova-plugin/issues/9#issuecomment-993658943
You have to open the connection before print and disconnect after. Here i attach an example.
object = {
type: 'tcp;
title: 'Printer;
ip: '192.168.1.211'; //ur IP
port: 9100;
id: 'printer;
}
printController;
async printThermal(object) {
let data = {
type: object.type,
address: object.ip,
mmFeedPaper: 700,
dotsFeedPaper: 100,
port: 9100,
id: object.id, // Use an unique identifier for each printer i. e. address:port or name
text:
'[L]\n' +
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
'[L]\n' +
'[C]================================\n' +
'[L]\n'
+ '<0A0A0A0A0A1B>i<0D0A>'
}
this.printController = await ThermalPrinter.printFormattedTextAndCut(
data,
() => {
console.log('Successfully printed!');
this.discconectPrinter(object)
},
(error) => {
console.error('Printing error', error.error);
}
);
}
discconectPrinter(object) {
console.log("Desconectando impresora" + object.id);
this.printController = ThermalPrinter.disconnectPrinter(
{
type: object.type,
address: object.ip,
port: 9100,
id: object.id, // Use an unique identifier for each printer i. e. address:port or name
} as PrinterToUse,
() => {
console.log('Successfully disconnected!');
},
(error) => {
console.error('Disconnecting error', error);
}
);
}
If u dont disconnect printer after printing other devices cannot connect, hope it Helps. U can message me if u need it.
when i was trying to print after few prints showing error Connection reset and Broken pipe issue can you please guide me how we can solve this issue