简体   繁体   English

PHP / JavaScript无需打开即可打印文档

[英]PHP / JavaScript Print Document Without Opening It

I need to send a file to a local workstations default printer, but I do not want the user to have to interact with downloading it or deal with a popup. 我需要将文件发送到本地工作站的默认打印机,但是我不希望用户必须与下载文件或弹出窗口进行交互。 The interface is a local web intranet webpage. 该界面是本地Web Intranet网页。

<select name=”s-1” id=”s_1”>
<option value=”0”>Please Select…</option>
<option value =”file1.doc”>File1.doc</option>
<option value =”file2.doc”>File2.docx</option>
<option value =”file3.doc”>File3.doc</option>
</select>
<input type=”button” name=”b_1” id=”b_1” value=”Print Selected File”>

All files will be Microsoft Word .doc or .docx files. 所有文件均为Microsoft Word .doc或.docx文件。 The workstations are terminals and don't have any office products installed. 工作站是终端机,没有安装任何办公产品。 I just want to send a selected file directly to the terminals default printer with either JavaScript or PHP with "onclick" or "post" events. 我只想使用“ onclick”或“ post”事件,使用JavaScript或PHP将所选文件直接发送到终端默认打印机。

Provided that it's intranet page, can you just identify user's own printer from LDAP, etc.? 如果是Intranet页面,您能否仅从LDAP等中识别用户自己的打印机? Do you have print server(s) in the network? 网络中是否有打印服务器? If so, send it directly from PHP to the print server. 如果是这样,请将其直接从PHP发送到打印服务器。 It may be tricky however to print .doc or .docx from PHP script without external calls to MS Office or LibreOffice. 但是,从PHP脚本打印.doc或.docx而不用外部调用MS Office或LibreOffice可能很棘手。

If the above is not possible, try to use Java of Flash applet to print from the browser. 如果上述方法不可行,请尝试使用Flash of applet的Java从浏览器进行打印。 It may be useful to convert the documents to PDF before. 之前将文档转换为PDF可能会很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM