Bil*_*ill 40 printing web-services
我正在开发一个需要静默打印的Web应用程序 - 没有用户参与.实现这一目标的最佳方法是什么?它不喜欢它可以严格使用Javascript,也不是Flash和/或AIR.我见过的最接近的是Java applet.
我可以理解为什么只有任何一个网站能够做到这一点是一个坏主意.此特定实例适用于内部应用程序,如果用户需要将URL添加到受信任站点列表,安装插件等,则完全可以接受.
小智 32
以下是您需要执行的操作,以便在不显示打印首选项对话框的情况下立即打印Firefox.
在Firefox的位置栏中输入about:config并按Enter键.
右键单击页面上的任意位置,然后选择New> Boolean
输入首选项名称print.always_print_silent,然后单击"确定".
我发现它在某个地方,它帮助了我
正如@Axel所写,Firefox有print.always_print_silent选项.
对于Chrome,请使用该--kiosk-printing选项跳过"打印预览"对话框:
编辑用于启动Chrome的快捷方式,然后添加"--kiosk-printing",然后重新启动Chrome.
注意:如果它不起作用,很可能是因为你没有完全停止Chrome,退出并重新登录肯定会有效.
您可以尝试以下两个代码示例:
1:
<script>
function Print() {
alert ("THUD.. another tree bites the dust!")
if (document.layers)
{
window.print();
}
else if (document.all)
{
WebBrowser1.ExecWB(6, 1);
//use 6, 1 to prompt the print dialog or 6, 6 to omit it
//some websites also indicate that 6,2 should be used to omit the box
WebBrowser1.outerHTML = "";
}
}
</script>
<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
Run Code Online (Sandbox Code Playgroud)
2:
if (navigator.appName == "Microsoft Internet Explorer")
{
var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = "";
}
else {
window.print();
}
Run Code Online (Sandbox Code Playgroud)
您可能需要将要测试的站点/页面添加到本地Intranet区域.
我们遇到了类似的问题.我们需要将支票打印到支票打印机,将标签打印到标签打印机,并将客户发票打印到零售店embrasse-moi的发票打印机.我们有虚拟计算机,角落,ipads,没有打印功能的iphone.打印发票功能基本上是一个无声的打印.将pdf写入服务器,并在本地使用shell脚本来检索和打印.
我们使用以下内容实现了最小库的完美解决方案:
在PHP中使用TCPDF来创建PDF.将PDF存储在服务器上.将它放在"打印队列"文件夹中.对于TCPDF的称赞,有点难学,但SICK SICK SICK.请注意,我们使用avery 5167每页打印80个标签,条形码具有完美的准确性.我们有标签,支票和发票打印队列.不同的文件夹主要针对不同的打
使用附带的shell脚本通过FTP连接到服务器,下载PDF,从服务器上删除PDF,将PDF发送到打印机,然后再删除PDF.
使用连接到打印机的本地计算机,在终端中运行脚本.显然修改您的打印机和路径.
因为你总是希望这个运行,并且因为你使用MAC,所以使用automator创建一个'app'.启动automator,将脚本放入"运行shell脚本"并保存.然后将该应用程序粘贴在登录项中.如果要查看MAC上的"输出"窗口,请参阅shell脚本下面的脚本.
BAM - 生病了.
这是shell脚本
#!/bin/bash
# Get a remote directory Folder
# List the contents every second
# Copy the files to a local folder
# delete the file from server
# send the file to a printer
# delete the file
# compliments of embrasse-moi.com
clear # clear terminal window
echo "##########################################"
echo "Embrasse-Moi's Remote Print Queue Script"
echo "##########################################"
#Local Print Queue Directory
COPY_TO_DIRECTORY=/volumes/DATA/test/
echo "Local Directory: $COPY_TO_DIRECTORY"
#Priter
PRINTER='Brother_MFC_7820N'
echo "Printer Name: $PRINTER"
#FTP Info
USER="user"
PASS="pass"
HOST="ftp.yourserver.com"
#remote path
COPY_REMOTE_DIRECTORY_FILES=/path
echo "Remote Print Queue Directory: $HOST$COPY_REMOTE_DIRECTORY_FILES"
echo 'Entering Repeating Loop'
while true; do
#make the copy to directory if not exist
echo "Making Directory If it Does Not Exist"
mkdir -p $COPY_TO_DIRECTORY
cd $COPY_TO_DIRECTORY
######################### WGET ATTEMPTS ############################################
#NOTE wget will need to be installed
echo "NOT Using wget to retrieve remote files..."
# wget --tries=45 -o log --ftp-user=$USER --ftp-password=$PASS ftp://ftp.yourserver.com$COPY_REMOTE_DIRECTORY_FILES/*.pdf
######################### FTP ATTEMPTS ############################################
echo "NOT Using ftp to retrieve and delete remote files..."
#This seems to fail at mget, plus not sure how to delete file or loop through files
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASS
cd $COPY_REMOTE_DIRECTORY_FILES
ls
prompt
mget *
mdel *
END_SCRIPT
echo "Examining Files in $COPY_TO_DIRECTORY"
for f in $COPY_TO_DIRECTORY/*.pdf
do
# take action on each file. $f store current file name
#print
echo "Printing File: $f To: $PRINTER"
lpr -P $PRINTER $f
# This will remove the file.....
echo "Deleting File: $f"
rm "$f"
done
echo "Script Complete... now repeat until killed..."
sleep 5
done
Run Code Online (Sandbox Code Playgroud)
和automator脚本,如果你想看到输出,保持应用程序与脚本选择运行苹果脚本选项:
on run {input, parameters}
tell application "Finder" to get folder of (path to me) as Unicode text
set workingDir to POSIX path of result
tell application "Terminal"
do script "sh " & "'" & workingDir & "script1.sh" & "'"
end tell
return input
end run
Run Code Online (Sandbox Code Playgroud)
我必须说实话,我在这里有点想大声说出来。但是,难道不能用小程序或某种被授予可信权限(例如内联网区域内的权限)的小程序(无论是Java还是其他什么)来完成吗? ?
可能值得研究一下可以向每个区域授予哪些权限?
跟着Google一下,我想你肯定有一个挑战,到目前为止我看到的大多数文章都涉及打印到连接到服务器的打印机。
如果是内部的,是否可以将打印从服务器路由到部门/用户打印机或其他设备?
| 归档时间: |
|
| 查看次数: |
62654 次 |
| 最近记录: |