Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Default printer

Status
Not open for further replies.

chicdog

Programmer
Feb 28, 2002
84
US
I have to print a report to the printer from a web page. Is there a way to get the default printer from a user's computer? I tried using PrinterSettings.InstalledPrinters then using IsDefaultPrinter to no avail.

chikey


 
I'm not sure how to do it in Asp.Net (or even if it's possible, since Asp.Net is server side).
I had to do the same thing (print a page), what I did is open the report in a new window, and on the top of the report I inserted a "Print this document" link, and in the onClick event of the link I had the following javascript code window.print();

Let me know if you want me to post a sample?
I hope this helps.

jerasi
 
That would be great, but would it be possible to specific tray (i.e. Envelope tray)?
 
Here is a sample file. Copy the code below and save it as an HTML file, then open the file in your browser.
As far as tray goes, when you click the "print.." link, the print dialog box comes up, you can choose more options from there.


<HTML>
<HEAD>
<SCRIPT lenguage=&quot;Javascript&quot;>
function PrintDocument()
{
window.print();
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE width=&quot;100%&quot; border=&quot;0&quot;>
<TR>
<TD colspan=&quot;2&quot; width=&quot;100%&quot;><font size=&quot;5&quot;>Sample document that needs printing</font><font size=&quot;2&quot;>  <a href=&quot;&quot; onClick=&quot;PrintDocument(); return(false);&quot;>Print this report</a></font></TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Employee Name</TD>
<TD width=&quot;70%&quot;>Description</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr. Wong</TD>
<TD width=&quot;70%&quot;>Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr, Wing</TD>
<TD width=&quot;70%&quot;>Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr. Wong</TD>
<TD width=&quot;70%&quot;>Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr, Wing</TD>
<TD width=&quot;70%&quot;>Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr. Wong</TD>
<TD width=&quot;70%&quot;>Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr, Wing</TD>
<TD width=&quot;70%&quot;>Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr. Wong</TD>
<TD width=&quot;70%&quot;>Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width=&quot;30%&quot;>Mr, Wing</TD>
<TD width=&quot;70%&quot;>Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
</TABLE>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top