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/
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥20 ue5运行的通道视频都会有白色锯齿
- ¥20 用雷电模拟器安装百达屋apk一直闪退
- ¥15 算能科技20240506咨询(拒绝大模型回答)
- ¥15 自适应 AR 模型 参数估计Matlab程序
- ¥100 角动量包络面如何用MATLAB绘制
- ¥15 merge函数占用内存过大
- ¥15 Revit2020下载问题
- ¥15 使用EMD去噪处理RML2016数据集时候的原理
- ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
- ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数