示例#1
0
 public static void Print(IPrinter printer)
 {
     CommonPrinter commonPrinter = new CommonPrinter(printer);
     //commonPrinter.ShowPreviewPrinter();
     GlobalPrintSetting printSetting = StaticCacheManager.GetConfig<GlobalPrintSetting>();
     if (printSetting.PrintModel == "ֱ�Ӵ�")
     {
         commonPrinter.Print();
     }
     else if (printSetting.PrintModel == "ѡ���ӡ��")
     {
         commonPrinter.ShowPreviewPrinter();
     }
     else
     {
         commonPrinter.Preview();
     }
 }
示例#2
0
 private void btnPrintCode39_Click(object sender, EventArgs e)
 {
     string idcard=this.txtIdCard.Text.Trim();
         string name = this.txtName.Text.Trim();
         if (idcard.Length == 0)
         {
             MessageBoxHelper.Show("请输入港澳通行证号码再按打印!");
         }
         else  if (name.Length == 0)
         {
             MessageBoxHelper.Show("请输入姓名再按打印!");
         }
         else
         {
             HKMacoPrinter printer = new HKMacoPrinter(idcard,name);
             CommonPrinter commonPrinter = new CommonPrinter(printer);
             //commonPrinter.Preview();
             commonPrinter.Print();
         }
 }
        private void PrintTask()
        {
            while (this.counter < this.stopCounter)
            {
                // StringBuilder msg = new StringBuilder();
                //int i = HotPrinterImporter.PrintLine(this.txtPrintContent.Text.Trim(), msg);
                //if (i == 0)
                //{
                TemplatePrintObject printer = new TemplatePrintObject(config);
                CommonPrinter commonPrinter = new CommonPrinter(printer);
                commonPrinter.SetPaperSize(config.PageWidth, config.PageHeight);
                commonPrinter.Print();
                counter++;
                //}
                this.setHint("正在打印:" + counter.ToString() + "页!");
                System.Threading.Thread.Sleep(this.threadSleepTime * 1000);
                if (this.counter == this.stopCounter)
                {

                    this.setHint("打印完成:" + counter.ToString() + "页!");
                    this.btnBeginPrint.Enabled = true;
                    this.btnEndPrint.Enabled = false;
                    break;
                }

            }
        }
示例#4
0
        public static void PrintWindowsTemplate(object obj, string templateFile)
        {
            string path = Application.StartupPath + "\\Template\\" + templateFile;
            using (StreamReader fileStream = new StreamReader(path, Encoding.Default))
            {
                string content = fileStream.ReadToEnd();
                string[] rows = content.Replace("\r\n", "?").Split("?".ToCharArray());
                List<string> lists=new List<string>(rows.Length);
                for (int i = 0; i < rows.Length; i++)
                {
                   // if (rows[i].Length > 0)
                       lists.Add(ConvertPrintTemplate(obj, rows[i]));
                }

                ListStringPrintObject printer = new ListStringPrintObject(lists,new System.Drawing.Font("宋体",9),10);
                CommonPrinter commonPrinter = new CommonPrinter(printer);
                //commonPrinter.SetPaperSize(config.PageWidth, config.PageHeight);
                commonPrinter.Print();
            }
        }
 private void btnPrint_Click(object sender, EventArgs e)
 {
     TemplatePrintObject printer = new TemplatePrintObject(config);
     CommonPrinter commonPrinter = new CommonPrinter(printer);
     commonPrinter.SetPaperSize(config.PageWidth, config.PageHeight);
     commonPrinter.Print();
 }