Set a print job name in C#

[print job name]

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 print a small sample document.

// Print the document.
private void btnPrint_Click(object sender, EventArgs e)
{
    // Select the printer.
    pdocFile.PrinterSettings.PrinterName = cboPrinter.Text;

    // Set the print document name.
    pdocFile.DocumentName = txtDocumentName.Text;

    // Print.
    pdocFile.Print();
}

The code sets the PrintDocument object’s PrinterSettings.PrinterName property so output goes to the printer you selected from the ComboBox at the top of the form.

It then sets the DocumentName property to the value you entered in the TextBox.

Finally the code calls the PrintDocument object’s Print method to start printing.

If you click the Print button and then check the selected printer’s spool (before the document has finished printing), you should see the print job name that you entered.


Download Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in printers, printing, system and tagged , , , , , , , , , , , , , . Bookmark the permalink.

One Response to Set a print job name in C#

  1. manal says:

    i have a 3d object inside a scaterview.i am not able to manipulate that object because all the mouse event are disabled by the scaterviewitem which has the 3d object. plz help me to display 3d object that can be zoomin,zoomout,toggled,etc by touch.plz mail me if u have any information

Leave a Reply

Your email address will not be published. Required fields are marked *