如何从 ASP.NET 打印外部文件(XLS、PDF、DOCX 等)?
我们有一个经典 ASP 中的应用程序,允许用户将文件“附加”到信息上。 这些可以是 PDF、电子表格、Word 文档等。
在新的 ASP.NET 版本中,一个请求的选项是“全部打印”(一名用户遇到的情况是有 34 个附加文件,在当前系统中,她必须单独打开并打印每一份)。
这些文件保存在单独的目录中 - 不嵌入数据库中。 数据库只包含一个 ID 号和文件扩展名,因此如果用户想查看“2182.xls”,应用程序就会打开它(在这种情况下会打开一个 Excel 窗口)。
当您只有完全限定的文件名时,有没有办法将文件发送到打印机? (在上面的例子中我大概可以重复 34 次)
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请记住,您的 asp.net 代码在 Web 服务器上运行。 它不在客户端计算机上运行,并且不知道那里安装了哪些打印机(如果有!)。 这就是网络的运作方式; 根据设计,网络应用程序所能做的就是打开当前页面的打印对话框。 如果再多的话,黑客就会利用我们的网络浏览器发送与传真机上收到的垃圾邮件相同的垃圾邮件。
也就是说,您可能可以做一些事情:
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: