/// <summary>
        /// 打印开始,公用程序,启动打印引擎/获取标签路径/打印机名称/加载标签文档
        /// </summary>
        /// <param name="sLabel">标签名称,可为空,默认值为BC_DEFAULT.btw</param>
        /// <param name="sPrinter">打印机名称,可为空,默认值为系统默认打印机</param>
        private static bool PrintLabelStart(string sLabel, string sPrinter)
        {
            try
            {
                //打印任务开始
                Log.WriteLogStart();
                //启动打印引擎
                btEngine.Start();
                Log.WriteLog("--Print Engine Start OK--");

                //获取标签完整路径
                sLabelNameFull = ConfigLoad.GetLabelNameFull(sLabel);
                Log.WriteLog("--Get full label path : " + sLabelNameFull + "--");
                //获取打印机名称
                sPrinterName = string.IsNullOrEmpty(sPrinter) ? ConfigLoad.GetDefaultPrinterName() : sPrinter;
                Log.WriteLog("--Printer : " + sPrinterName);
                //加载标签模板,指定打印机
                btFormatDoc = btEngine.Documents.Open(sLabelNameFull, sPrinterName);
                Log.WriteLog("--FormatDoc opened--");
                return(true);
            }
            catch (Exception ex)
            {
                Log.WriteLog(ex.Message);
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// 打印开始,公用程序,启动打印引擎,打开标签模板,指定打印机
 /// </summary>
 /// <param name="sLabel">标签名称,为空时获取默认值=当前路径\BC_DEFAULT.btw</param>
 /// <param name="sPrinter">打印机名称,为空时获取系统默认打印机</param>
 public void PrintStart(string sLabel, string sPrinter)
 {
     //启动打印引擎
     btEngine.Start();
     Log.WriteLog("-- Print Engine Start OK --");
     //获取默认标签完整路径
     sLabelNameFull = ConfigLoad.GetLabelNameFull(sLabel);
     Log.WriteLog("-- Default label path : " + sLabelNameFull + " --");
     //指定打印机名称
     sPrinterName = string.IsNullOrEmpty(sPrinter) ? ConfigLoad.GetDefaultPrinterName() : sPrinter;
     Log.WriteLog("-- Default Printer : " + sPrinterName + " --");
     //加载标签模板,指定打印机
     btFormatDoc = btEngine.Documents.Open(sLabelNameFull, sPrinterName);
     Log.WriteLog("-- FormatDoc opened --");
 }