是否可以访问Google Chrome打包应用中网络中安装的打印机? [英] Is it possible to access printer installed in network in Google Chrome Packaged App?

查看:91
本文介绍了是否可以访问Google Chrome打包应用中网络中安装的打印机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建Google Chrome打包应用.我需要通过封闭"网络(未通过USB连接)访问可用的打印机.显然,不是我选择Chrome Cloud Print API,因为我所说的是封闭"网络,因此无法访问互联网(除了我需要非常快速地打印,因此即使有互联网,我也无法承受通过Cloud等待的费用)几秒钟即可打印出来.).我已经完成研究,到目前为止,在Google Chrome打包应用中似乎无法实现.如果我忽略了某些内容,或者有解决方法,请告诉我.

I am building a Google Chrome Packaged App. I have a requirement to access printer available via a "Closed" Network (not connected as USB). Obviously Chrome Cloud Print API is NOT my option, since I'm talking about "Closed" network, hence no internet access (besides I need to print very fast, so even if I had internet I could not afford to go via Cloud and wait few seconds to print.). I have done my research, so far this seems to be NOT possible in Google Chrome Packaged App. Please let me know if I've overlooked something, or if there's a workaround.

非常感谢.

推荐答案

如果可以在打印前要求用户确认,可以使用window.print(),该方法在Chrome应用程序中具有以下限制: 1)有一个错误可能导致OS X崩溃( http://crbug.com/297179 ) ,尽管该错误已在Chrome的Canary和Dev版本中修复,但要花费几周的时间才能将其升级到Beta和Stable版本; 2)在Window和Linux/Chrome OS上,打印预览面板的大小限于要打印的窗口的大小,因此您需要确保该窗口足够大以使用户可以访问所有打印预览UI

If you're OK with requiring user confirmation before printing, then you can use window.print(), which works in Chrome apps with a couple of limitations: 1) There was a bug that could cause crashes on OS X (http://crbug.com/297179), and while this bug is fixed in the Canary and Dev versions of Chrome, it will take a few weeks for the fix to make its way to the Beta and Stable versions; 2) On Window and Linux/Chrome OS, the size of the print preview panel is limited to the size of the window being printed, so you need to make sure that window is large enough to make all of the print preview UI accessible to users.

由于window.print()到目前为止在Chrome应用程序中使用不多,因此您可能会遇到其他人未曾看到过的问题.如果这样做,请在 http://crbug.com/new 上进行报告.

Because window.print() has not been used very much so far in Chrome apps, you may run into issues with it that have not been seen by others. If you do, please report them at http://crbug.com/new.

如果需要在未经用户确认的情况下进行打印,则程序可能必须使用套接字API与打印机或打印服务器直接通信(如xmarcos在对该问题的另一种答复中所述).您可能需要使用pdf.js之类的内容(如将画布转换为pdf 中所述)将要打印的内容转换为宾客会明白的东西.

If you need the print to happen without user confirmation, your program may have to use the sockets API to communicate directly with your printer or print server (as described by xmarcos in another response to this question). You will probably need to use something like pdf.js (as described at Converting canvas to pdf) to convert what you want to print to something your pinter will understand.

这篇关于是否可以访问Google Chrome打包应用中网络中安装的打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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