从浏览器静音打印 [英] Silent Print From Browser

查看:26
本文介绍了从浏览器静音打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去几天我进行了大量研究,并在这个问题上给予了足够的关注.我想要实现的是使用打印按钮直接从网络打印.我不想出现浏览器打印弹出窗口.将有 2 台打印机连接到我的 Web 应用程序,我希望自动选择打印机.

I have researched so much in the last few days and have given my enough head in that issue. What I'm trying to achieve is to print directly from web using a print button. I don't want to browser print popup to appear. There will be 2 printers attached to my web application and I want the printer selection automatically.

我知道使用 PHP 或没有任何浏览器扩展或 active x 插件是不可能的.

I know that it is not possible with PHP or without any browser extension or active x plugin.

我还想了一个解决方案,即在通过用户系统安装 Java 套接字客户端应用程序时使用 Web 套接字发送打印请求.

I also thought a solution to send the print request using web sockets while a java socket client application installation over the user system.

请建议我任何节省时间的问题的解决方案

Please suggest me any time saving solution to my problem

推荐答案

我研究了 chrome 扩展,fire fox 插件
- Faizan Afzal 3 月 28 日 15:54
I've looked into the chrome extensions, fire fox addon
- Faizan Afzal Mar 28 at 15:54

在上面的评论中,您提到您已经研究了 Chrome 扩展程序和 FireFox 插件,但是这些浏览器中已经内置了禁用打印对话框的功能.
如果您正在制作的网络应用程序将在受控环境中运行(您可以在其中管理哪些浏览器访问它以及它们的配置方式),您可以相当轻松地做到这一点.

Chrome
首先,转到 chrome://settings/ 并将您的主页更改为 Web 应用程序.接下来,在桌面上为 Chrome 浏览器创建一个快捷方式,然后右键单击它以打开属性窗口.在目标"输入字段中,将 --kiosk --kiosk-printing 添加到位置的末尾.应用更改,关闭所有 Chrome 窗口并单击快捷方式.这应该会让您进入全屏(信息亭模式),并且当您尝试打印时,它应该会自动在默认打印机上打印,而不会显示弹出窗口.

FireFox
在 FireFox 上,转到 about:config 并同意任何警告消息.然后,右键单击页面上的某处并创建一个New -> Boolean".它会提示您输入名称和状态.对于名称,输入 print.always_print_silent,对于状态,将其设置为 true.然后您需要保存更改并重新启动您打开的所有 FireFox 窗口.如果您尝试打印某些内容,它将不再需要显示弹出窗口,而是会自动在默认打印机上打印.

以这种方式配置的这些浏览器中的任何一个,您都可以使用标准 window.print(); JavaScript 打印方法,无需任何类型的服务器端交互.

批处理文件?
如果您想要更简单的方法来执行这些操作,您可以使用这两个命令提示符脚本,它们会自动配置和/或运行它们以满足您的需要:

Chrome:

In the above comment, you mentioned that you've looked into Chrome extensions and FireFox addons, however there is already the functionality built into these browsers to disable the print dialog.
If the web application you're making will be run in a controlled environment (where you manage which browsers access it and how they're configured), you can fairly easily do this.

Chrome
Firstly, go to chrome://settings/ and change your home page to the web application. Next, make a shortcut for the Chrome browser on your desktop then right click on it to open the properties window. In the 'Target' input field, add --kiosk --kiosk-printing to the end of the location. Apply the changes, close all Chrome windows and click on the shortcut. This should put you in full screen (kiosk mode) and when you attempt t print, it should automatically print on the default printer without a pop-up window being displayed.

FireFox
On FireFox, go to about:config and agree to any warning messages. Then, right click somewhere on the page and create a "New -> Boolean". It will prompt you for a name and a state. For the name, enter print.always_print_silent and for the state, set it to true. Then you will need to save changes and restart any FireFox windows you have open. If you attempt to print something, it will no longer require the pop-up window to be displayed and will automatically print on the default printer.

With either of these browsers configured in this way, you can use the standard window.print(); JavaScript method to print without needing any kind of server-side interaction.

Batch Files?
If you'd like an easier way to do these, you can use these two command prompt scripts which will automatically configure and/or run them to suit your needs:

Chrome:

cd Program Files (x86)GoogleChromeApplication
chrome.exe --kiosk --kiosk-printing

火狐:

FOR /D %%G in ("%APPDATA%MozillaFirefoxProfiles*.default") DO SET prof=%%G
cd %prof%
echo user_pref("print.always_print_silent", true);>>prefs.js
cd ..
cd Program Files (x86)Mozilla Firefox
firefox.exe

这篇关于从浏览器静音打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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