溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

C# 惠普打印機(jī) 打印

發(fā)布時間:2020-07-17 09:30:26 來源:網(wǎng)絡(luò) 閱讀:635 作者:星星鑫鑫 欄目:編程語言

打印機(jī)通用:

        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;//調(diào)整位置信息  

            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();

            }  

        }


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI