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.
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.
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="Javascript">
function PrintDocument()
{
window.print();
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE width="100%" border="0">
<TR>
<TD colspan="2" width="100%"><font size="5">Sample document that needs printing</font><font size="2"> <a href="" onClick="PrintDocument(); return(false);">Print this report</a></font></TD>
</TR>
<TR>
<TD width="30%">Employee Name</TD>
<TD width="70%">Description</TD>
</TR>
<TR>
<TD width="30%">Mr. Wong</TD>
<TD width="70%">Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width="30%">Mr, Wing</TD>
<TD width="70%">Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
<TR>
<TD width="30%">Mr. Wong</TD>
<TD width="70%">Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width="30%">Mr, Wing</TD>
<TD width="70%">Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
<TR>
<TD width="30%">Mr. Wong</TD>
<TD width="70%">Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width="30%">Mr, Wing</TD>
<TD width="70%">Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
<TR>
<TD width="30%">Mr. Wong</TD>
<TD width="70%">Short, stubby, and annoying and oh yah, he's also the president of the company</TD>
</TR>
<TR>
<TD width="30%">Mr, Wing</TD>
<TD width="70%">Sweet and sometimes sower too, he's the cousing of the president</TD>
</TR>
</TABLE>
</BODY>
</HTML>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.