• WPF不调用Bartender 打印标贴


    // 点击打印按钮

    	private void butPrint_MouseUp(object sender, RoutedEventArgs e)  //打印
            {
                try
                {
                    if (RemoveDG.Items.Count == 0)
                    {
                        MessageBox.Show("請先進行資料查詢!");
                        return;
                    }
                    List<DataRow> ls_lo_Remove_DTab = new List<DataRow>();
                    for (int i = 0; i < RemoveDG.Items.Count; i++)
                    {
                        System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
                        pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 220, 76);
                        pd.DocumentName = i.ToString();
                        pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pd_PrintPage);
                        pd.Print();
                        int ls_Nubmer = i + 1;
                        labSearchCountDesc.Content = "已打印" + ls_Nubmer.ToString() + "笔";
                    }
                }
                catch (Exception lo_Ex)
                {
                    MessageBox.Show("butPrint_MouseUp is Fail,ErrMsg: " + lo_Ex.Message);
                }
            }
    

    //生成二维码(点阵图)

    	//生成二维码点阵图
            public static Bitmap BytesToBitmap(byte[] buffer)
            {
                MemoryStream ms = new MemoryStream(buffer);
                Bitmap bmp = new Bitmap(ms);
                ms.Close();
                return bmp;
            }
    

    //绘制标贴模板

    	//绘制标贴模板
            private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ev)
            {
                try
                {
                    System.Drawing.Printing.PrintDocument pd = (System.Drawing.Printing.PrintDocument)sender;
                    int li_DataIdx = int.Parse(pd.DocumentName);
    
                    EquBaseInfoHelper.EquBaseInfoHelper ls_EquBaseInfoHelper = new EquBaseInfoHelper.EquBaseInfoHelper();
                    byte[] ls_QRCode = ls_EquBaseInfoHelper.MerryLebleGetCode(ps_AssetNo);
    
                    Bitmap lo_QRCode = BytesToBitmap(ls_QRCode);//生成点阵图
                    System.Drawing.Rectangle destRect = new System.Drawing.Rectangle(159, 28, 40, 40);
                    ev.Graphics.DrawImage(lo_QRCode, destRect, 0, 0, lo_QRCode.Width, lo_QRCode.Height, System.Drawing.GraphicsUnit.Pixel);
    
    				//设定字体样式
                    System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
                    System.Drawing.Font font = new System.Drawing.Font("SimHei", 11f, GraphicsUnit.Pixel);
                    System.Drawing.Font font1 = new System.Drawing.Font("SimHei", 12, GraphicsUnit.Pixel);
                    ev.Graphics.DrawString(ps_Dept, font1, brush, 63, 26);
                    for (int i = 0; i < ps_AssetNo.Length; i++)
                    {
                        string ls = ps_AssetNo.Substring(i, 1).ToString();//单个字符为一位
                        ev.Graphics.DrawString(ls, font, brush, 63 + 4.2f * i, 44);
                    }
                    ev.Graphics.DrawString(ps_AssetName, font1, brush, 63, 59);
                }
                catch (Exception lo_Ex)
                {
                    MessageBox.Show("pd_PrintPage is Fail, ErrMsg=:" + lo_Ex.Message);
                }
            }

      

  • 相关阅读:
    pointer-like classes, 关于智能指针
    non-explicite-one-argumen-constructor
    车道标线分割与分类
    matlab变量更新
    matlab求余
    MATLAB中图像的读取与显示
    提取文件一部分内容
    NetCore3.1 使用 mongoDb 存储日志,提升查询效率
    C#代码实现阿里云消息服务MNS消息监听
    盘点这些年我出的书,以及由此得到的收获
  • 原文地址:https://www.cnblogs.com/aDoc/p/12923343.html
Copyright © 2020-2023  润新知