您好,登錄后才能下訂單哦!
打印機通用:
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();
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。