c#打印如何调用 斑马打印机 GK888t

zwwkj 2014-09-15 02:51:11
我想问个问题,我现在有GK888t打印机,如何用c# 代码实现打印功能,谢谢
...全文
2737 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuyong19900903 2015-01-05
  • 打赏
  • 举报
回复
我也遇到这种情况,调用斑马打印机打印条码,用的是usb口,请问楼主有解决方案吗
allen0118 2014-09-17
  • 打赏
  • 举报
回复
设置默认打印机不就可以了吗,直接将模板内容发送给打印机:
 /// <summary>
        /// 返回默认打印机
        /// </summary>
        /// <returns></returns>
        public static string GetDefaultPrinter()
        {
            System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();
            return p.DefaultPageSettings.PrinterSettings.PrinterName;
        }
冬夜 2014-09-16
  • 打赏
  • 举报
回复
 barcode 这是打印到文件后的内容,我这里修改了下,你可以自己试试
冬夜 2014-09-16
  • 打赏
  • 举报
回复
用ZebraDesigner 编辑模版,然后打印到文件 每次打印的时候调用这个模版并替换里面的内容。
namespace ZebraPrintDemo
{
    class POSPrinter
    {
        const int OPEN_EXISTING = 3;
        string prnPort = "COM7"; //这里修改连接的口  我是串口的
        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
        private static extern IntPtr CreateFile(String lpFileName, int dwDesiredAccess, int dwShareMode,
            int lpSecurityAttributes, int DwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile);
        public POSPrinter(string prnPort)
        {
            this.prnPort = prnPort;
        }
        public string PrintLine(string str)
        {
            try
            {
                IntPtr iHandle = CreateFile(prnPort, 0x40000000, 0, 0, OPEN_EXISTING, 0, 0);
                if (iHandle.ToInt32() == -1)
                    return string.Format("{0} Port Open Failed", prnPort);
                else
                {
                    FileStream fs = new FileStream(iHandle, FileAccess.ReadWrite);
                    StreamWriter sw = new StreamWriter(fs, Encoding.Default);
                    sw.WriteLine(str);
                    sw.Close();
                    fs.Close();
                    return "";
                }
            }
            catch (Exception)
            { throw; }
        }
    }
}

        private void btnSave_Click(object sender, EventArgs e)
        {
            List<string> lotID = new List<string>();
            lotID.Add("111111111");
            lotID.Add("222222222");
            lotID.Add("333333333");
            lotID.Add("444444444");
            lotID.Add("555555555");
            lotID.Add("666666666");
            lotID.Add("777777777");
            lotID.Add("888888888");
            lotID.Add("999999999");
            lotID.Add("000000000");
            PrintBarcode("");
            txtLabel.Focus();
            txtLabel.SelectAll();
        }

        private void PrintBarcode(List<string> lotID)
        {
            string barcode = string.Format(@"CT~~CD,~CC^~CT~
                                            ^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD15^JUS^LRN^CI0^XZ
                                            ^XA
                                            ^MMT
                                            ^PW599
                                            ^LL0599
                                            ^LS0
                                            ^BY2,3,38^FT11,48^BCN,,Y,N
                                            ^FD>;{0}^FS
                                            ^BY2,3,40^FT248,51^BCN,,Y,N
                                            ^FD>;{1}^FS
                                            ^BY2,3,47^FT10,128^BCN,,Y,N
                                            ^FD>;{2}^FS
                                            ^BY2,3,47^FT242,125^BCN,,Y,N
                                            ^FD>;{3}^FS
                                            ^BY2,3,40^FT12,202^BCN,,Y,N
                                            ^FD>;{4}^FS
                                            ^BY2,3,47^FT243,205^BCN,,Y,N
                                            ^FD>;{5}^FS
                                            ^BY2,3,47^FT9,280^BCN,,Y,N
                                            ^FD>;{6}^FS
                                            ^BY2,3,47^FT249,290^BCN,,Y,N
                                            ^FD>;{7}^FS
                                            ^BY2,3,40^FT13,371^BCN,,Y,N
                                            ^FD>;{8}^FS
                                            ^BY2,3,38^FT244,362^BCN,,Y,N
                                            ^FD>;{9}^FS
                                            ^PQ1,0,1,Y^XZ
                                        ", lotID[0],lotID[1],lotID[2],lotID[3],lotID[4],lotID[5],lotID[6],lotID[7],lotID[8],lotID[9]);
            POSPrinter prn = new POSPrinter("COM7");
            string strmsg = prn.PrintLine(barcode);
            if (strmsg != "")
                MessageBox.Show(strmsg);
        }
zwwkj 2014-09-15
  • 打赏
  • 举报
回复
引用 3 楼 happy09li 的回复:
[quote=引用 2 楼 zwwkj 的回复:] 这个应该是装了驱动了,用的是USB口的,你有类似的代码木有啊,急
http://www.cnblogs.com/zhcw/archive/2011/11/30/2269083.html[/quote] 貌似不行啊
熙风 2014-09-15
  • 打赏
  • 举报
回复
引用 2 楼 zwwkj 的回复:
这个应该是装了驱动了,用的是USB口的,你有类似的代码木有啊,急
http://www.cnblogs.com/zhcw/archive/2011/11/30/2269083.html
zwwkj 2014-09-15
  • 打赏
  • 举报
回复
这个应该是装了驱动了,用的是USB口的,你有类似的代码木有啊,急
shawn_yang 2014-09-15
  • 打赏
  • 举报
回复
小票打印机吧,有两种方式。 一种是有驱动的,装完你就和普通打印机差不多调用。 一种直接用串口或者并口写数据,参考这个打印机的说明书即可。

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧