I am working on a project for school. I am wondering if there is a way in PHP to listen for print jobs and store them once received? I currently have a webserver that is accepting webhooks from other applications, parsing out the JSON and storing in a MsSQL. Is this the wrong path to take? thanks
1条回答 默认 最新
- doufangyan6862 2019-07-05 11:08关注
Ok – I don’t know if this is a solution but here is my attempt at trying to help :)
Disclaimer: I am not affiliated to any of the links posted here and (or) make no recommendations.
General assumptions:
- PHP is the server side language used in all instances (the theory should work with others as well – using PHP as the question was tagged as such)
- Sender and receiver servers are different (it is more easier if both are on the same box – but not a show stopper)
- Access to both sender and receiver webservers
- Windows set up (WAMP or alternative)
- You are securing your set up / directory accesses as you go along
Option 1 (Custom sender / receiver)
On the box that is sending the print request:
- Create a PHP script to output the files to a temp directory
- Create file with required extension (please see documentation if required)
- Put contents
- Close connection / file - https://www.php.net/manual/en/function.file-put-contents.php
- Use powershell or alternative to put the files in the temp directory into a remote directory on the
- https://blogs.msdn.microsoft.com/luisdem/2016/08/31/powershell-how-to-copy-a-local-file-to-remote-machines/
- Run this at an interval of your choice
On the box that is receiving the file:
Create a PHP script to read files on remote
Show files to print in a list which can be downloaded to local terminal / device and printed
Option 2 (Leverage an existing print server)
In this option you would only need to amend the sender webserver config: [inspired by: https://www.hashbangcode.com/article/printing-directly-php]
- Download php_printer.dll for your version (https://windows.php.net/downloads/pecl/snaps/printer/0.1.0-dev/)
- Enable in php.ini via: printer.default_printer=PHP_INI_ALL extension=php_printer.dll
-
Set the printer as your print server address and send your output to print directly from the Webserver as follows from your application:
` $data= "Hello"; printer_set_option($ph, PRINTER_MODE, "RAW"); printer_write($ph, $data); printer_close($ph); } else "Couldn't connect..."; ?>'
Option 3 (Use a plugin): https://www.neodynamic.com/products/printing/raw-data/php/
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 fluent里模拟降膜反应的UDF编写
- ¥15 MYSQL 多表拼接link
- ¥15 关于某款2.13寸墨水屏的问题
- ¥15 obsidian的中文层级自动编号
- ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
- ¥15 神经网络模型一直不能上GPU
- ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
- ¥20 wpf datagrid单元闪烁效果失灵
- ¥15 券商软件上市公司信息获取问题
- ¥100 ensp启动设备蓝屏,代码clock_watchdog_timeout