Title: Send a printout directly to a specific printer in C#
To send a printout directly to a specific printer, simply set the PrintDocument object's PrinterSettings.PrinterName property to the printer's name. This example uses the following code to print directly to the printer named "HP Deskjet F300 Series."
// Print.
private void btnPrint_Click(object sender, EventArgs e)
{
// Select the printer.
pdocSmiley.PrinterSettings.PrinterName =
"HP Deskjet F300 Series";
// Print.
pdocSmiley.Print();
}
The code sets the printer's name and then calls the PrintDocument object's Print method to immediately send the printout to that printer.
The PrintDocument object named pdocSmiley has a PrintPage event handler that prints a smiley face. Download the example so see how that and other details work.
Download the example to experiment with it and to see additional details.
|