views:

501

answers:

1

We have an application in classic ASP that allows user to 'attach' files to information. These can be PDFs, spreadsheets, Word documents, etc.

In the new ASP.NET version, one requested option was for a "Print All" (one user has a situation where there are 34 attached files and, in the current system, she has to open and print each one individually).

The files are kept in a separate directory - not embedded in the database. The database simply contains an ID number and the file's extension so the application would then go out and open "2182.xls" if the user wanted to see it (which would open an Excel window in that case).

Is there a way to send a file to a printer when all you have is the fully qualified filename? (Which I could presumably repeat 34 times in the above example)

Thanks in advance.

+1  A: 

Remember that your asp.net code runs on the web server. It's not running on the client computer and has no knowledge of what printers (if any!) are installed there. That's just the way the web works; by design, all a web app can do is open the print dialog for the current page. Anything more, and hackers would use our web browsers for the same kind of spam you get at a fax machine.

That said, there might be some things you can do:

  • Add an activex control, flash app, silverlight app, firefox plugin, or other plugin code to support the feature.
  • Render all the attachments on the server into one html document with appropriate styles and javascript so it prints correctly and prompts the user on load.
  • If this if for a local intranet site (as opposed to public internet) where you have special knowledge of what printers are available for the current user, you could setup all the printers on your server and have it print to the correct location on behalf of the user.
Joel Coehoorn
While the site is SOMEWHAT public, only local 'intranet' users would be permitted the option of automated printing. I beginning to think that a 'companion desktop application' might be the way to go. That way I think I can open up local instances of Word/Excel/Adobe and do the equivalent of a ".Print" for each file.
David