Closed RintuMondal06 closed 4 years ago
Hello sir, I'm using this to print on ATPOS thermal printer. The problem is it's not printing the whole data. I'm stuck here for a long time. Please help me. Below is my print function, please let me know where I'm going wrong.
testPrint(address , details , products:any = []) {
let CMD = data; this.buff.clear(); this.buff.write(CMD.TEXT_FORMAT.TXT_ALIGN_CT); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_ON); this.buff.write(CMD.TEXT_FORMAT.TXT_4SQUARE); this.buff.write(CMD.TEXT_FORMAT.TXT_FONT_A); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_ON); this.buff.write("Kolkata Basket"); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.TEXT_FORMAT.TXT_NORMAL); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_OFF); this.buff.write(CMD.TEXT_FORMAT.TXT_FONT_A); this.buff.write("Everything at your door"); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); //2 lines this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.TEXT_FORMAT.TXT_ALIGN_LT); this.buff.write(CMD.TEXT_FORMAT.TXT_FONT_A); this.buff.write("Customer Name :" + details.name); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write("Phone :" + details.mobile); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write("Address :" + details.shipping_address + "," + details.shipping_pin + "," + details.shipping_city); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.TEXT_FORMAT.TXT_ALIGN_CT); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_ON); this.buff.write("----------------------"); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_OFF); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.TEXT_FORMAT.TXT_ALIGN_LT); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_OFF); this.buff.write("OrderId :" + details.unique_code); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write("Delivery Date :" + details.delivery_date); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write("Delivery Time :" + details.time_span); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.TEXT_FORMAT.TXT_ALIGN_CT); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_ON); this.buff.write("----------------------"); this.buff.write(CMD.TEXT_FORMAT.TXT_BOLD_OFF); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.TEXT_FORMAT.TXT_ALIGN_LT); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); for (var index = 0; index < products.length; index++) { this.buff.write(CMD.TEXT_FORMAT.TXT_NORMAL); this.buff.write(products[index].product_name + "*" + products[index].quantity); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); } this.buff.write("Total Amount : Rs." + details.total_amount); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write("~ Thank You ~"); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); this.buff.write(CMD.FEED_CONTROL_SEQUENCES.CTL_LF); let xyz=this.connectBT(address).subscribe(data=>{ this.btSerial.clear(); this.btSerial.write(this.buff.buffer).then(dataz=>{ this.buff.clear(); let mno=this.alertCtrl.create({ title:"Print SUCCESS!", buttons:['Dismiss'] }); mno.present(); xyz.unsubscribe(); },errx=>{ console.log("WRITE FAILED",errx); let mno=this.alertCtrl.create({ title:"ERROR "+errx, buttons:['Dismiss'] }); mno.present(); }); },err=>{ console.log("CONNECTION ERROR",err); let mno=this.alertCtrl.create({ title:"ERROR "+err, buttons:['Dismiss'] }); mno.present(); });
}
The project works for bluetooth. Since I am assuming you are connecting directly to a thermal printer, I don't think my code works.
Hello sir, I'm using this to print on ATPOS thermal printer. The problem is it's not printing the whole data. I'm stuck here for a long time. Please help me. Below is my print function, please let me know where I'm going wrong.
testPrint(address , details , products:any = []) {
}