打印機(jī)通用:
禹城網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、自適應(yīng)網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)于2013年開始到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。
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();
}
}