Esempio n. 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            // StringBuilder sw = new StringBuilder();
            // sw.Append("       S0011234567892asdfghj");
            // sw.Append("订单编号1:" );
            // sw.Append("订单编号2:" );
            // sw.Append("订单编号3:" );
            // sw.Append("订单编号4:" );

            printDocument = new PrintDocument();
            string printerName = printDocument.PrinterSettings.PrinterName;
            var    currPrinter = PrinterFactory.GetPrinter("printerName", PaperWidth.Paper76mm);

            currPrinter.PrintWaitInfoTicket(new WaitInfoV1d0(), "测试餐厅");
            //currPrinter.PrintText("排队序号S001");
            // currPrinter.NewRow();
            // currPrinter.PrintText("序号:");
            // currPrinter.NewRow();
            // currPrinter.PrintText("前面还有00位");
            // currPrinter.NewRow();
            // currPrinter.PrintText("排队时间:" + DateTime.Now.ToString("yyyyMMdd hh:mm:ss"));
            //// currPrinter.PrintLine();
            // //currPrinter.Finish();
            // currPrinter.Finish();
        }
Esempio n. 2
0
        public void PrintImageTest()
        {
            var printer = PrinterFactory.GetPrinter("Microsoft XPS Document Writer", PaperWidth.Paper80mm);

            printer.PrintText("一二三四五六七八", width: 0.3f);
            printer.PrintText("一二三四五六七八", width: 0.2f, offset: 0.4f);
            printer.NewRow();
            printer.PrintText("我是新的行");
            printer.NewRow();
            printer.Finish();
        }
Esempio n. 3
0
        public void TextStringAlignmentTest()
        {
            var printer = PrinterFactory.GetPrinter("Microsoft XPS Document Writer", PaperWidth.Paper80mm);

            printer.PrintText("正", Printer.Models.FontSize.Huge);
            printer.NewRow();
            printer.PrintText("正");
            printer.NewRow();
            printer.PrintText("正", Printer.Models.FontSize.micro);
            printer.NewRow();
            printer.Finish();
        }
Esempio n. 4
0
        public void FinishTest()
        {
            var printer = PrinterFactory.GetPrinter("Microsoft XPS Document Writer", PaperWidth.Paper80mm);

            printer.NewRow();
            printer.NewRow();
            printer.PrintText("永辉超市", Printer.Models.FontSize.Huge, StringAlignment.Center);
            printer.NewRow();
            printer.NewRow();
            printer.NewRow();
            printer.PrintText("操作员:张三");
            printer.PrintText(DateTime.Now.ToString("HH:mm:ss"), stringAlignment: StringAlignment.Far);
            printer.NewRow();
            printer.PrintLine();
            printer.NewRow();
            printer.PrintText("商品");
            printer.PrintText("单价", offset: 0.35f);
            printer.PrintText("数量", offset: 0.65f);
            printer.PrintText("总价", stringAlignment: StringAlignment.Far);
            printer.NewRow();
            printer.PrintLine();
            printer.NewRow();
            printer.PrintText("**长白山大萝卜,跳楼吐血大甩卖,不甜不要钱**", width: 0.35f);
            printer.PrintText("6.00", width: 0.2f, offset: 0.35f);
            printer.PrintText("2.00", width: 0.2f, offset: 0.65F);
            printer.PrintText("12.00", stringAlignment: StringAlignment.Far);
            printer.NewRow();
            printer.NewRow();
            printer.PrintText("大螃蟹", width: 0.35f);
            printer.PrintText("6.000000000001", width: 0.2f, offset: 0.35f);
            printer.PrintText("1", width: 0.2f, offset: 0.65F);
            printer.PrintText("6.000000000001", offset: 0.8f, width: 0.2f);
            printer.NewRow();
            printer.PrintLine();
            printer.NewRow();
            var bitmap = new Bitmap("qr.png");

            printer.PrintImage(bitmap, StringAlignment.Center);
            printer.NewRow();
            printer.PrintLine();
            printer.NewRow();
            printer.PrintText("感谢光临,欢迎下次再来!", stringAlignment: StringAlignment.Center);
            printer.NewRow();
            printer.Finish();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var printer = PrinterFactory.GetPrinter("Microsoft XPS Document Writer", PaperWidth.Paper80mm);

            var server = new WebSocketServer("ws://0.0.0.0:2399");

            server.Start(socket =>
            {
                socket.OnOpen = () =>
                {
                    Console.WriteLine("连接socket成功");
                };
                socket.OnClose = () =>
                {
                    Console.WriteLine("断开socket成功");
                };
                socket.OnMessage = msg =>
                {
                    var printData = JsonConvert.DeserializeObject <List <PrintUnit> >(msg);
                    foreach (var item in printData)
                    {
                        switch (item.Type)
                        {
                        case "text":
                            Console.WriteLine("打印文字");
                            printer.PrintText(item.Content);
                            break;

                        case "finish":
                            Console.WriteLine("结束打印输出文档");
                            printer.Finish();
                            break;

                        default:
                            break;
                        }
                    }
                };
            });

            Console.ReadKey();
        }
        public void stert_Print()
        {
            int item    = 0;
            var printer = PrinterFactory.GetPrinter("XP-58", PaperWidth.Paper58mm);

            PrintQueueHelper.GetPrintQueueName();
            printer.NewRow();
            printer.NewRow();
            printer.PrintText(Title1.Text, FontSize.Huge, StringAlignment.Center);
            printer.NewRow();
            printer.NewRow();

            if (User.Text != "")
            {
                printer.NewRow();
                printer.PrintText(User.Text);
                printer.NewRow();
            }

            printer.PrintLine();
            printer.NewRow();
            printer.PrintText("商品");
            printer.PrintText("单价", offset: 0.35f);
            printer.PrintText("数量", offset: 0.65f);
            printer.PrintText("总价", stringAlignment: StringAlignment.Far);
            printer.NewRow();
            printer.PrintLine();

            if (num1.Value != 0)
            {
                printer.NewRow();
                printer.PrintText(item1.Text, width: 0.35f);
                printer.PrintText(up1.Value.ToString(), width: 0.2f, offset: 0.35f);
                printer.PrintText(num1.Value.ToString(), width: 0.2f, offset: 0.65F);
                printer.PrintText(price1.Text, stringAlignment: StringAlignment.Far);
                printer.NewRow();
                item++;
            }

            if (num2.Value != 0)
            {
                printer.NewRow();
                printer.PrintText(item2.Text, width: 0.35f);
                printer.PrintText(up2.Value.ToString(), width: 0.2f, offset: 0.35f);
                printer.PrintText(num2.Value.ToString(), width: 0.2f, offset: 0.65F);
                printer.PrintText(price2.Text, stringAlignment: StringAlignment.Far);
                printer.NewRow();
                item++;
            }
            if (num3.Value != 0)
            {
                printer.NewRow();
                printer.PrintText(item3.Text, width: 0.35f);
                printer.PrintText(up3.Value.ToString(), width: 0.2f, offset: 0.35f);
                printer.PrintText(num3.Value.ToString(), width: 0.2f, offset: 0.65F);
                printer.PrintText(price3.Text, stringAlignment: StringAlignment.Far);
                printer.NewRow();
                item++;
            }
            if (num4.Value != 0)
            {
                printer.NewRow();
                printer.PrintText(item4.Text, width: 0.35f);
                printer.PrintText(up4.Value.ToString(), width: 0.2f, offset: 0.35f);
                printer.PrintText(num4.Value.ToString(), width: 0.2f, offset: 0.65F);
                printer.PrintText(price4.Text, stringAlignment: StringAlignment.Far);
                printer.NewRow();
                item++;
            }
            if (num5.Value != 0)
            {
                printer.NewRow();
                printer.PrintText(item5.Text, width: 0.35f);
                printer.PrintText(up5.Value.ToString(), width: 0.2f, offset: 0.35f);
                printer.PrintText(num5.Value.ToString(), width: 0.2f, offset: 0.65F);
                printer.PrintText(price5.Text, stringAlignment: StringAlignment.Far);
                printer.NewRow();
                item++;
            }

            while (item < 5)
            {
                printer.NewRow();
                printer.NewRow();
                printer.NewRow();
                printer.NewRow();
                item++;
            }


            printer.PrintLine();
            printer.NewRow();
            printer.PrintText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), stringAlignment: StringAlignment.Near);
            printer.NewRow();
            printer.PrintText(EndText.Text, stringAlignment: StringAlignment.Near);
            printer.PrintText("合计: " + tp.Text, stringAlignment: StringAlignment.Far);
            printer.NewRow();
            printer.Finish();

            RawPrinterHelper.SendStringToPrinter("XP-58", Convert.ToString((char)29) + "V" + (char)1);
        }