Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnPrint_Click(object sender, EventArgs e)
- {
- PrintDocument PrintDoc = new PrintDocument();
- PrintDoc.PrinterSettings.PrinterName = printerList.SelectedItem.ToString();
- PrintDoc.BeginPrint += new PrintEventHandler(BeginPrintEH);
- PrintDoc.EndPrint += new PrintEventHandler(EndPrintEH);
- PrintDoc.PrintPage += new PrintPageEventHandler(PrintPageEH);
- PrintDoc.Print();
- }
- public void BeginPrintEH(object sender, PrintEventArgs peArgs)
- {
- redBrush = new SolidBrush(Color.Red);
- }
- public void EndPrintEH(object sender, PrintEventArgs peArgs)
- {
- redBrush.Dispose();
- }
- public void PrintPageEH(object sender, PrintPageEventArgs ppeArgs)
- {
- Graphics g = ppeArgs.Graphics;
- Font font = new Font("Verdana", 20);
- Rectangle rect = new Rectangle(50, 50, 200, 200);
- g.DrawString("Hello Printer", font, redBrush, rect);
- }
Advertisement
Add Comment
Please, Sign In to add comment