C# 惠普打印机 打印

发布时间:2020-07-17 09:30:26 作者:星星鑫鑫
来源:网络 阅读:608

打印机通用:

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)

        {

            Font font = new Font("宋体", 12);

            Brush bru = Brushes.Black;

            Image bitmap = new Bitmap(panel1.BackgroundImage.Width, panel1.BackgroundImage.Height);

            Graphics g = e.Graphics;  //先建立画布  

            g.DrawImage(bitmap, 0, 0);

            int x = 0;//调整位置信息  

            int y = 0;

            foreach (Control item in panel1.Controls)

            {

                if (item is TextBox)

                {

                    Control tx = (item as Control);

                    g.DrawString(tx.Text, font, bru, tx.Left + x, tx.Top + y);

                }

                if (item is PictureEdit)

                {

                    Control tx = (item as Control);

                    e.Graphics.DrawImage(pictureEdit1.Image, tx.Left + x, tx.Top + y);

                }

            }

        }

        //打印

        private void simpleButton1_Click(object sender, EventArgs e)

        {

            PrintText();

            PrintDialog pdia = new PrintDialog();

            PrintDocument pdoc = new PrintDocument();             

            pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);

            if (pdia.ShowDialog() == DialogResult.OK)

            {

                pdoc.Print();

            }  

        }


推荐阅读:
  1. C#小票打印(通用)
  2. 怎么在C#中打印PDF文档

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

信息 private 通用

上一篇:python批量读取txt文件的方法

下一篇:vue在项目中调用腾讯云的滑动验证码的详细教程

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》