Ejemplo n.º 1
0
 public string Print2Bitmap(string url, string fileName, int lineNum)
 {
     try
     {
         string text2 = Utils.Substitute(AppDomain.CurrentDomain.BaseDirectory, "\\") + fileName;
         FileTransferHttp.DownloadPicture(url, text2);
         LogTools.Info("临时图片路径:" + text2);
         Bitmap bmp = new Bitmap(text2);
         try
         {
             this.PrintCode(bmp);
         }
         catch (Exception ex2)
         {
             throw ex2;
         }
         finally
         {
             bmp.Dispose();
         }
         for (int i = 0; i < lineNum - 1; i++)
         {
             this.lc.Write(" " + Environment.NewLine);
         }
         return(string.Empty);
     }
     catch (Exception ex)
     {
         LogTools.Info("打印图片异常:" + ex.ToString());
         throw ex;
     }
 }
Ejemplo n.º 2
0
        public bool Print2Bitmap(PrintLineModel m)
        {
            string fileName = "tmpBmp.bmp";
            string text2    = Utils.Substitute(AppDomain.CurrentDomain.BaseDirectory, "\\") + fileName;

            try
            {
                FileTransferHttp.DownloadPicture(m.content, text2);
            }
            catch (Exception ex)
            {
                try
                {
                    FileTransferHttp.GetImageByHttp(m.content, text2);
                }
                catch (Exception ex2)
                {
                    LogTools.Debug(string.Format("[Pos 1003] 图片下载地址:{0}。下载异常两次:1:{1}。2:{2}。", m.content, ex.ToString(), ex2.ToString()));
                    return(false);
                }
            }
            try
            {
                Invoke1.PrintMiddleBitmapFile0(new StringBuilder(text2), 0);
            }
            catch (Exception ex2)
            {
                LogTools.Debug(string.Format("[Pos 1003] 打印图片tmpBmp.bmp异常:{0}", ex2.ToString()));
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
 public string Print2Bitmap(string url, string fileName, int lineNum)
 {
     try
     {
         string text2 = Utils.Substitute(AppDomain.CurrentDomain.BaseDirectory, "\\") + fileName;
         FileTransferHttp.DownloadPicture(url, text2);
         LogTools.Info("临时图片路径:" + text2);
         Bitmap bmp = new Bitmap(text2);
         try
         {
             //前置回车
             for (int i = 0; i < lineNum - 1; i++)
             {
                 this.posPrinter.PrintNormal(2, " " + Environment.NewLine);
             }
             int rst = 0;
             #region 图片
             try
             {
                 rst = this.posPrinter.SetBitmap(1, 2, text2, -11, -2);
             }
             catch (Exception ex)
             {
                 LogTools.Debug(ex.Message);
             }
             rst = this.posPrinter.PrintBitmap(2, text2, -11, -2);
             #endregion
         }
         catch (Exception ex)
         {
             LogTools.Info("打印图片异常:" + ex.ToString());
             throw ex;
         }
         finally
         {
             bmp.Dispose();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(string.Empty);
 }