private void PrintLocalDefaultImage(PosPrinter actualPrinter) { try { Image Dummy = Image.FromFile(Properties.Settings.Default.DefaultAd); string directory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); string fileName = directory + @"/default.bmp"; Bitmap ADimg = Helpers.ConvertPNGToBitmap(Dummy); ADimg.Save(fileName, ImageFormat.Bmp); actualPrinter.PrintBitmap(PrinterStation.Receipt, fileName, PosPrinter.PrinterBitmapAsIs, PosPrinter.PrinterBitmapCenter); } catch (Exception ex) { AddLog(ex.ToString(),true); } actualPrinter.PrintNormal(PrinterStation.Receipt, "\r\n\r\nPowered by www.docketplace.com.au"); actualPrinter.PrintNormal(PrinterStation.Receipt, "\r\n\r\n\r\n\r\n"); actualPrinter.CutPaper(10); AddLog("Local Image printed",false); }
public void print(int printNum) //打印内容 { // bool status = false; int mPrintNum = 1; mPrintNum = printNum; //Initialization string iHeader = @"***功夫团膳***"; string iOrderid = " CC1001 "; //iOrderid = "TS02000201506060020"; string iConsumer = "顾客:" + " 郭灿 "; string iAddress = "地址:" + " 三林镇如日商务园 "; string iTelephone = "电话:" + " 13312345678 "; string iRemark = "备注:" + " 无 "; string iSalesSlip = "发票: " + " 无 "; string iSubmitTime = "订单提交时间:" + " 2017-07-11 12:01:02"; string iDeliveredTime = "预计送达时间:" + " 2017-07-11 13:00:00 "; string iDivisionLine = "************************************************"; /**************************************************/ string iItemTitle = @"名称 数量 原价(元) "; /****************************************************/ string iItemDisTitle = @"优惠名称 数量 优惠(元)"; /*****************************************************/ string iFreight = "外 送 费:" + " 3元 "; string iTotalAmount = "订单合计:" + " 29元 "; string iDiscountAmount = "优惠金额:" + " 2元 "; string iPayAmount = "应付金额:" + " 27元 "; string payTypeStr = " 微信支付 "; string iPayType = "支付方式:" + payTypeStr; string iCash = "应收现金:" + " 0元 "; /*************** 订单编码 ************/ string foot1 = "感谢惠顾功夫团膳"; string foot2 = "功夫团膳餐厅" + "XX0001"; string foot3 = "查询电话:" + "15112345678"; int[] RecLineChars = new int[MAX_LINE_WIDTHS] { 0, 0 }; //When outputting to a printer,a mouse cursor becomes like a hourglass. //Cursor.Current = Cursors.WaitCursor; //for (int i = 0; i < mPrintNum; i++) //{ // //if (m_Printer.CapRecPresent) // //{ // // if (async == true) // // { // // m_Printer.AsyncMode = true; // // } // try // { // //m_Printer.TransactionPrint(PrinterStation.Receipt // // , PrinterTransactionControl.Transaction); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "\u001b|bC" + "\u001b|2C" + iHeader + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "\u001b|bC" + iOrderid + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iConsumer + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iAddress + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iTelephone + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iRemark + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iSalesSlip + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|80uF"); m_Printer.PrintNormal(PrinterStation.Receipt, iSubmitTime + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iDeliveredTime + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|300uF"); m_Printer.PrintNormal(PrinterStation.Receipt, iDivisionLine + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF"); m_Printer.PrintNormal(PrinterStation.Receipt, iItemTitle + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iDivisionLine + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF"); m_Printer.PrintNormal(PrinterStation.Receipt, iItemDisTitle + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iDivisionLine + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF"); m_Printer.PrintNormal(PrinterStation.Receipt, iFreight + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iTotalAmount + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iDiscountAmount + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iPayAmount + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, iPayType + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|4C" + "\u001b|bC" + iCash + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF"); // if (m_Printer.CapRecBarCode == true) // { // m_Printer.PrintBarCode(PrinterStation.Receipt, // iOrderid, // BarCodeSymbology.Code128, 1000, // m_Printer.RecLineWidth, PosPrinter.PrinterBarCodeCenter, // BarCodeTextPosition.None); // } m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "\u001b|4C" + foot1 + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + foot2 + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|300uF"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + foot3 + "\n"); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|fP"); // m_Printer.TransactionPrint(PrinterStation.Receipt // , PrinterTransactionControl.Normal); // } // catch (PosControlException e) // { // Console.WriteLine("**********************************"); // Console.WriteLine(e.ErrorCode); // Console.WriteLine("+++++++++++++++++++++++++++++++++++"); // System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n"); // } // } // m_Printer.AsyncMode = false; }