Category Archives: printing

Select and print multiple files in C#

This example lets you easily print multiple files. You can use it, for example, to print all of the .cs files in a project’s directory. Select a printer from the ComboBox at the top. Enter or select a directory and … Continue reading

Posted in files, printers, printing, system | Tagged , , , , , , , , , , , , | 7 Comments

Set a print job name in C#

By default, when you send a PrintDocument to a printer, the printer spool shows the job’s name as “document.” You can change the print job name by setting the PrintDocument object’s DocumentName property. This example uses the following code to … Continue reading

Posted in printers, printing, system | Tagged , , , , , , , , , , , , , | 1 Comment

Determine the default printer in C#

When this example starts, the following code lists the printers and selects the default printer. private void Form1_Load(object sender, EventArgs e) { // Find all of the installed printers. foreach (string printer in PrinterSettings.InstalledPrinters) { cboPrinter.Items.Add(printer); } // Find and … Continue reading

Posted in printing, system | Tagged , , , , , , , , , | 1 Comment

Print a text file in C#

This example lets you select a printer and file, and then print the file on the selected printer. (Actually this version just displays a print preview. To send the file directly to the selected printer, see the example Send a … Continue reading

Posted in printers, printing, system | Tagged , , , , , , , , , , , , , , , , , | 2 Comments

Restart the print spooler in C#

Every now and then my computer gets confused and thinks the printer is offline. That wouldn’t be so bad except Windows doesn’t provide a simple way to bring the printer back online. Basically you need to shutdown and restart the … Continue reading

Posted in printing, system | Tagged , , , , , , , , , , | Leave a comment

Print images in C#

This example shows a simple way to print images. When you print, the PrintDocument object’s PrintPage event handler provides a Graphics object named e.Graphics. That object’s DrawImage method can draw a picture on the printed surface. To print an image, … Continue reading

Posted in graphics, image processing, printing | Tagged , , , , , , , , , , | Leave a comment

Print at full scale in C#

This example shows how you can print at full scale so objects drawn on the screen are the same size when printed. Note that your screen and printer are probably not calibrated exactly so the result will not match perfectly. … Continue reading

Posted in drawing, GDI+, graphics, printing | Tagged , , , , , , , , , , , , , , , , | 2 Comments

Select printer resolution in C#

This example shows how to let the user select a printer resolution. When you set a PrintDocument object’s printer, its DefaultPageSettings.PrinterSettings.PrinterResolutions collection contains PrinterResolution objects representing the printer’s available resolutions. For example, you can select one of these to print … Continue reading

Posted in printers, printing | Tagged , , , , , , , , | Leave a comment

Let the user select a printer and then send a printout directly to it in C#

When it starts, the program uses the following code to list the available printers in a ComboBox. // List the available printers. private void Form1_Load(object sender, EventArgs e) { foreach (string printer in PrinterSettings.InstalledPrinters) cboPrinter.Items.Add(printer); } This code loops through … Continue reading

Posted in printers, printing | Tagged , , , , , , , , , , | Leave a comment

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 … Continue reading

Posted in printers, printing | Tagged , , , , , , , , | 3 Comments