get the default printer

  • Thread starter Thread starter Ravikanth[MVP]
  • Start date Start date
R

Ravikanth[MVP]

Hello,


You can use the PrintDocument component to use the
default printer. If you don't specify a printer to the
PrintDocument object, by default, it will
use the default printer.
This is a sample code;

private void print_Click(object sender, System.EventArgs
e)
{
printDocument1.Print(); //It will use default
printer
}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, new Rectangle
(500, 500, 500, 500));
}

If you dont want to print a document, but just want to
retrieve the information about the default printer. You
can create a PrintDocument and access its PrinterSettings
Property. You can get the information such as PinterName
and PaperSize from the Property.

PrintDocument printDocument1 = new PrintDocument();
MessageBox.Show
(printDocument1.PrinterSettings.PrinterName);

For more information about PrintDocument please see:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/cpref/html/
frlrfSystemDrawingPrintingPrintDocumentClassTopic.asp

I hope this is helpful for you.

Ravikanth[MVP]
 
Thanks for answering.
However this is not useful for me as i'm sending to print
through a Word object which automatically sends to the
default printer.
That is why i have to change it before sending (i've
already achieved this) and then return to the previous
settings.
If you have another suggestion, please let me know.
Thanks
Pablo
 
Back
Top