您好,登錄后才能下訂單哦!
打印機(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();
}
}
免責(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)容。