十万火急, 客户催得我想跳楼这是我的打印代码 public PrintDocument pdDocument;
        public PageSetupDialog dlgPageSetup;
        public PrintPreviewDialog ppd;
        public PrintDialog pd;
        private string[] lines;        public string[] Lines
        {
            get
            {
                if (ViewState["Lines"] != null)
                    return ViewState["Lines"] as string[];
                return null;
            }
            set
            {
                lines = value;
                ViewState["Lines"] = lines;
            }
        }        public PrintHelper()
        {
            pdDocument = new PrintDocument();
            dlgPageSetup = new PageSetupDialog();
            ppd = new PrintPreviewDialog();
            pd = new PrintDialog();
            dlgPageSetup.Document = pdDocument;
            pd.Document = pdDocument;
            ppd.Document = pdDocument;
            pdDocument.PrintPage += new PrintPageEventHandler(pdDocument_PrintPage);
            pdDocument.BeginPrint += new PrintEventHandler(pdDocument_BeginPrint);
            pdDocument.EndPrint += new PrintEventHandler(pdDocument_EndPrint);
        }        void pdDocument_EndPrint(object sender, PrintEventArgs e)
        {
            lines = null;
        }        void pdDocument_BeginPrint(object sender, PrintEventArgs e)
        {        }        /// <summary>
        /// 开始打印 
        /// </summary>
        public void Print()
        {
            try
            {
                pdDocument.Print();
            }
            catch (InvalidPrinterException ex)
            {
                File.WriteAllText("c://test.txt", ex.Message, Encoding.UTF8);
            }
        }
        void pdDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            int x = 20;
            int y = 20;
            int count = 0;
            while (count < Lines.Length)
            {
                e.Graphics.DrawString(Lines[count], new Font("微软雅黑", 20), System.Drawing.Brushes.Black, x, y);
                y += 50;
                count++;
            }
            count = 0;
            e.HasMorePages = false;
        }
打印机用的佳博GP-7635III 76m针式打印机。 
无奈无论如何也打印不出来。求高手指点 !!!

解决方案 »

  1.   

    对 PCBased-POS 机编写打印程序,最好使用 ESC/POS 之类的概念为基础。例如,你是否考虑到不定长票据、自动裁纸刀半切纸(如果全切纸那么就会掉下来了)的功能?尽量不要偷懒地把他当作一个办公室里的普通打印机来编程。那样做,非常不专业。
      

  2.   

    记得很早以前用过针式打印机,是内置中文字体的,所以只发送文本内容就可以打印机出来了,但只能打文字,大小通过命令控制,比较简陋。
    楼主先用WORK或EXCEL软件打印一下,确认打印机有没有问题
      

  3.   

    pdDocument与用什么打印机么有关系
      

  4.   

    ESC/POS  是打印机的专用命令??    怎么调用的。