发送文件到打印机用C# [英] Send document to printer with C#

查看:100
本文介绍了发送文件到打印机用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经给出了一个内部​​Web应用程序的要求将文档发送到打印机透明。这个想法是,用户可以选择就近的打印机,网络应用程序会送他们的打印作业,他们选择的打印机。

I've been given a requirement for an internal web application to send documents to a printer transparently. The idea would be that the user can select their nearest printer, and the web application would send their print jobs to the printer they selected.

我们要推出针对有大炮,所以我的问题的第一台打印机是:我怎么会去发送文件打印aross网络特定佳能?该型加农炮是问题是一个iR5570和会说将主要是文档的Word和PDF

The first printer we have to roll out against are Canons, so my questions is: How would I go about sending a document to print aross the network to a specific Canon? The type of Cannon is question is an iR5570 and the documents that will be said will mainly be Word and PDFs

我目前的工作我的方式,通过可怕的,只有IE浏览器开发者佳能网站,但我还挺希望有人能指出我在正确的方向或第三方组件指向我:)

I'm currently working my way through the terrible, IE only Canon Developer site, but I'm kinda hoping someone can point me in the right direction or point me at a 3rd party assembly :)

推荐答案

在这个问题的关键短语是Web应用程序。

The key phrase in that question is 'web application'.

在仅使用HTML +的Javascript通过HTTP正常的Web应用程序,你的无法的只需直接将文档发送到打印机。这就是原因Web浏览器中存在一个,没有这个功能大家的打印机将收​​集同一种垃圾,一个公共传真机做的。

In a normal web app using only HTML+Javascript over HTTP, you can't just send a document directly to a printer. That's one of the reasons web browsers exist, and without that functionality everyone's printer would collect the same kind of junk that a public fax machine does.

所以,你需要某种工作周围。一种选择是建立在共同的插件,如Flash,Silverlight的,Java小程序,甚至像Greasemonkey的。另一种是自定义插件,如托管的WinForms控制或自定义浏览器扩展。

So you need some kind of work-around. One option is to build on a common plug-in, like flash, silverlight, java applet, or even something like greasemonkey. Another is a custom plug-in, like a hosted winforms control or custom browser extension.

您很幸运,因为它看起来你有完全的控制(或knowlege)的部署环境,而这种环境下,如果比较均匀。这意味着你有其他人已经开始探索一个附加选项。如果你能在你的环境中安装的所有打印机到Web服务器,那么它使用内置在.net打印机类(在 System.Drawing.Printing 相当容易命名空间),列出那些打印机,无论他们展示给用户,使他们能够采摘或保留一些知识产权的到打印机映射表,然后直接打印从您的Web应用程序的打印机。请注意,这个方案可能需要您的应用程序以信任比其他需要更高层次的运行。

You are very fortunate, in that it looks like you have complete control (or knowlege of) the deployment environment, and that this environment if fairly homogenous. This means you have an additional option that others have started to explore. If you can install all of the printers in your environment to the web server, then it's fairly easy using the built-in .Net printer classes (in the System.Drawing.Printing namespace) to list out those printer, either show them to the user so they can pick or keep some kind of IP to Printer mapping table, and then print directly to that printer from your web app. Note that this scheme may require your app to run at a higher level of trust than would otherwise be required.

现在涉及到实际打印你的PDF和Word文档。对于杂技演员,检查此链接:结果
<一href=\"http://web.archive.org/web/20090206162133/http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm\"相对=nofollow> http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm (Wayback机器)结果
请注意,这是一个有点过时,但我相信这个概念仍然是有效的。你必须尝试一些,以确保其工作正常。

Now it comes to actually printing your PDF's and word documents. For acrobat, check this link:
http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm (Wayback machine)
Note that it's a little dated, but I believe the concept is still valid. You'll have to experiment some to make sure it works as expected.

对于Word,我不是一般的Office互操作性/​​自动化的Web应用程序的风扇。但在这种情况下,你没有编辑任何文件:只需加载它足够长的打印。此外,如果想依靠另一稀缺资源(打印机)的事实应该扩展超出你的Web服务器可以应付保持这个。那么,在Web项目中办公自动化是有道理的,你可能有一个罕见的情况。

For Word, I'm not normally a fan of Office interop/automation in a web app. But in this case you're not editing any documents: just loading it up long enough to print. And the fact that you're relying on another scarce resource (the printers) should keep this from scaling beyond what your web server could cope with. So you may have a rare case where Office automation in a web project makes sense.

这篇关于发送文件到打印机用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆