2

I have an ASP.NET 2.0 (C#) webpage with a link that pulls a blob from a MS SQL database and ouputs it in the appropriat file format, i.e., Word, WordPerfect, PDF.

My users would like to print these files with one click. Right now they have to click the link to open the file, then click the "Print" button within the application that they file opened.

In addition, I would like to send multiple documents to the printer, using one click, if possible.

Thanks.

Tod Birdsall
  • 17,877
  • 4
  • 38
  • 40

2 Answers2

2

Do you want to print to a Printer attached to the Server, or attached to the client?

If you want to print on the Client, you won't have much chance. For HTML Content, maybe some JavaScript or Flash could trigger the Print Dialog (not sure), but if it's a File that has to be opened in a third party application (i.e. PDF, DOC, XLS etc.), you're out of luck.

If it's an internal Network, you could possibly create a Desktop Application that is installed on every Client's PC that then triggers the Print.

If it is a Printer Attached to the Server, you can use the standard .net facilities for Printing, although you again may have to work around situations where you are trying to print PDF/DOC/XLS etc., because then you need to use Automation (either COM or something like SendKeys), which will cause you headaches on a Server.

So in Short: Not much you can do with only ASP.net at your disposal.

Michael Stum
  • 177,530
  • 117
  • 400
  • 535
  • This would be to a printer attached to the client. – Tod Birdsall Nov 10 '08 at 20:47
  • Then you have a problem. For security reasons, you will not be able to control a Third-Party Application from the Browser using JavaScript, so you would need some sort of Helper Utility that runs on the Client and triggers the print. – Michael Stum Nov 10 '08 at 20:50
0

The closest I've gotten to this is using Javascript:

<body onload="window.print()">
...
</body>

which will pop-up the print dialog when the page loads (see this post for more). If you think about it, you probably won't be able to do much else unless you are on an internal network. How would you like your computer to start printing pop-ups "automatically"?

Community
  • 1
  • 1
ine
  • 14,014
  • 8
  • 55
  • 80