在Web应用程序中将页面打印到不同的打印机 [英] Printing a page to different printers in a web app

查看:196
本文介绍了在Web应用程序中将页面打印到不同的打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个网络应用程序,可以处理用户的演示文稿,当提交时,发送到他们的本地系统打印机 - 订单的一部分将去B& W激光打印机,另一部分去另一个打印机的另一部分进程。

理想情况下,这将能够在任何主要系统上运行 - Linux,OSX或Windows。

这可能是一个打包的Chrome或Firefox应用程序或扩展,但我不知道是否有足够的访问系统打印机。 (我可以看到所有的打印机可用于我当前的chrome安装 - 但它们是否可用于扩展?)。我看不到任何演示或库中的代码。



我已经看到了NPAPI的引用,但是我不能确定这是否也是我需要的 - if所以我需要为每个主要平台或每种打印机编写一个应用程序?

可以从一个扩展名打印。只使用JavaScript,就是(如果你喜欢,你可以自由地使用C ++)。
扩展本质上就是浏览器:浏览器可以做的所有事情,也可以是扩展。



然而,关于使用打印机的文档并不多。确切地说,我没有意识到。但是,浏览器是开源的,UI主要是Javascript,所以你可以直接阅读代码。



printUtils.js 作为一个很好的起点来检查这可能如何工作。还有一个实现 nsIPrinterEnumerator 。请参阅 firefox-addon 的问题info部分一般来说,关于附加开发的入门和文档资源的集合。



我不认为 Chrome 扩展API 提供了控制打印方式的方法。



NPAPI 插件API不能提供足够的打印控制。你只是基本上得到一个缓冲区,但无法控制打印设置或自己开始打印。你当然可以作弊,让你的插件通过操作系统绕过浏览器直接打印一些东西,比如这些PDF阅读器。但是,应该指出的是,NPAPI插件是过去的...如果可能的话,不要开发新的插件。


I want to write a web app that can process a users presentation which when submitted, gets sent to their local system printers - one part of the order will go to B&W laser printer and another part goes to another printer for another process.

Ideally, this will be able to run on any of the major systems - Linux, OSX or Windows.

It could be a packaged Chrome or Firefox app or extension, but I can't tell if there is sufficient access to the system printers. (I can see all the printers available to my current chrome installation - but are they available to an extension?). I can't see the code in any demos or libraries.

I've seen reference to NPAPI, but I can't tell if that's what I need either - if so would I need to write an app for each of the major platforms or each kind of printer?

解决方案

In Firefox it is possible to print from an extension. Using only javascript, that is (you're free to mess about with C++ if you like). Extensions are essentially the browser: Everything the browser can do, an extension can, too.

There is however not much documentation about using the printer. To be precise, there is none that I'm aware of. However, the browser is open source, and the UI is mostly Javascript, so you can just read the code.

printUtils.js would be a good starting point to check out how this might work. Also there is a component implementing nsIPrinterEnumerator. See the info section for a collection of "Getting started" and documentation resources about add-on development in general.

I don't think the Chrome extension API provides ways to control printing the way you'd need.

The NPAPI plugin API does not provide enough control over printing. You just basically get a buffer to draw into, but no way to control printing setting or initiate printing yourself. You could cheat of course, and have your plugin directly print something via OS bypassing the browser, like e.g. those PDF readers do. However, it should be noted that NPAPI plugins are the past... Don't develop new ones, if possible.

这篇关于在Web应用程序中将页面打印到不同的打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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