By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 1,868 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

get the default printer

P: n/a
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]

-----Original Message-----
Friends,

how can i get the name of the default printer??. I'm
working with winforms. VB,C#, nevermind.

Thanks a lot
Pablo
.

Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
-----Original Message-----
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 PrinterSettingsProperty. 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]

-----Original Message-----
Friends,

how can i get the name of the default printer??. I'm
working with winforms. VB,C#, nevermind.

Thanks a lot
Pablo
.

.

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.