• 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);
                }
            }

      

  • 相关阅读:
    Spring Boot四:配置文件详解properties
    程序员常去的14个顶级开发社区
    Spring Boot二:创建第一个web工程 hello world
    Java架构工程师知识图
    Java高效开发12个精品库
    华为员工:表面光鲜 工作十年买不起房
    如果你是一个程序员,又要踏足人工智能领域,应该要知道哪些语言
    H5表单提交上传图片
    转:正则表达式
    转载:jsp九大内置对象和四大作用域
  • 原文地址:https://www.cnblogs.com/aDoc/p/12923343.html
Copyright © 2020-2023  润新知